From 8b2b9d5c9488b1d24702d1d3c393ca280510f438 Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Sat, 9 Sep 2023 00:55:55 +0300 Subject: [PATCH] feat: remove Entity Queue (#490) --- src/Views/ContentBase.vala | 4 ++-- src/Views/Timeline.vala | 21 +-------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/Views/ContentBase.vala b/src/Views/ContentBase.vala index 76f73d342..e9ac4ac29 100644 --- a/src/Views/ContentBase.vala +++ b/src/Views/ContentBase.vala @@ -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; } @@ -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) { diff --git a/src/Views/Timeline.vala b/src/Views/Timeline.vala index 6839a8015..f7b6b7651 100644 --- a/src/Views/Timeline.vala +++ b/src/Views/Timeline.vala @@ -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; @@ -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); @@ -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 (); } @@ -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 (); @@ -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 ());