Skip to content

Commit

Permalink
feat: remove Entity Queue (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Sep 8, 2023
1 parent 5b83817 commit 8b2b9d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/Views/ContentBase.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ public class Tuba.Views.ContentBase : Views.Base {
public GLib.ListStore model;
protected Gtk.ListView content;
private bool bottom_reached_locked = false;
protected signal void reached_close_to_top ();
// protected signal void reached_close_to_top ();

public bool empty {
get { return model.get_n_items () <= 0; }
Expand Down Expand Up @@ -40,7 +40,7 @@ public class Tuba.Views.ContentBase : Views.Base {
scroll_to_top_rev.reveal_child = !is_close_to_top
&& scrolled.vadjustment.value + scrolled.vadjustment.page_size + 100 < scrolled.vadjustment.upper;

if (is_close_to_top) reached_close_to_top ();
// if (is_close_to_top) reached_close_to_top ();
}

protected virtual void bind_listitem_cb (GLib.Object item) {
Expand Down
21 changes: 1 addition & 20 deletions src/Views/Timeline.vala
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
public string url { get; construct set; }
public bool is_public { get; construct set; default = false; }
public Type accepts { get; set; default = typeof (API.Status); }
public bool use_queue { get; set; default = true; }

protected InstanceAccount? account { get; set; default = null; }

public bool is_last_page { get; set; default = false; }
public string? page_next { get; set; }
public string? page_prev { get; set; }
Entity[] entity_queue = {};

private Gtk.Spinner pull_to_refresh_spinner;
private bool _is_pulling = false;
Expand Down Expand Up @@ -75,7 +73,6 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
valign = Gtk.Align.START
};

reached_close_to_top.connect (finish_queue);
app.refresh.connect (on_refresh);
status_button.clicked.connect (on_refresh);

Expand All @@ -101,7 +98,6 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
~Timeline () {
debug (@"Destroying Timeline $label");

entity_queue = {};
destruct_account_holder ();
destruct_streamable ();
}
Expand Down Expand Up @@ -185,7 +181,6 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
}

public virtual void on_refresh () {
entity_queue = {};
scrolled.vadjustment.value = 0;
status_button.sensitive = false;
clear ();
Expand Down Expand Up @@ -229,26 +224,12 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase

public virtual void on_new_post (Streamable.Event ev) {
try {
var entity = Entity.from_json (accepts, ev.get_node ());

if (use_queue && scrolled.vadjustment.value > 1000) {
entity_queue += entity;
return;
}

model.insert (0, entity);
model.insert (0, Entity.from_json (accepts, ev.get_node ()));
} catch (Error e) {
warning (@"Error getting Entity from json: $(e.message)");
}
}

private void finish_queue () {
if (entity_queue.length == 0) return;
model.splice (0, 0, (Object[])entity_queue);

entity_queue = {};
}

public virtual void on_edit_post (Streamable.Event ev) {
try {
var entity = Entity.from_json (accepts, ev.get_node ());
Expand Down

0 comments on commit 8b2b9d5

Please sign in to comment.