aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobufa <bobufa@users.noreply.github.com>2018-07-31 10:55:15 +0200
committerbobufa <bobufa@users.noreply.github.com>2018-08-13 22:39:18 +0200
commitec25ecf2024fdd6b0dd70adef9ef644fad3f77f9 (patch)
treefa667093f18452abea127c35fc361dfe332c85c5
parenta6457286240700a83dbf4e3404e2a1180c95c8c0 (diff)
downloaddino-ec25ecf2024fdd6b0dd70adef9ef644fad3f77f9.tar.gz
dino-ec25ecf2024fdd6b0dd70adef9ef644fad3f77f9.zip
filter out messages outside the range of displayed messages
-rw-r--r--main/src/ui/conversation_summary/conversation_view.vala34
1 files changed, 23 insertions, 11 deletions
diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala
index 07259cc5..f9f0bef0 100644
--- a/main/src/ui/conversation_summary/conversation_view.vala
+++ b/main/src/ui/conversation_summary/conversation_view.vala
@@ -44,7 +44,7 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
content_populator = new ContentProvider(stream_interactor);
subscription_notification = new SubscriptionNotitication(stream_interactor);
- insert_item.connect(do_insert_item);
+ insert_item.connect(filter_insert_item);
remove_item.connect(do_remove_item);
Application app = GLib.Application.get_default() as Application;
@@ -160,6 +160,16 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
Idle.add(() => { on_value_notify(); return false; });
}
+ public void filter_insert_item(Plugins.MetaConversationItem item) {
+ print(@"$(meta_items.last().sort_time.compare(item.sort_time))\n");
+ print(@"$(meta_items.first().sort_time.compare(item.sort_time))\n");
+ if (at_current_content && meta_items.last().sort_time.compare(item.sort_time) < 0) {
+ do_insert_item(item);
+ } else if (meta_items.last().sort_time.compare(item.sort_time) > 0 && meta_items.first().sort_time.compare(item.sort_time) < 0) {
+ do_insert_item(item);
+ }
+ }
+
public void do_insert_item(Plugins.MetaConversationItem item) {
lock (meta_items) {
if (!item.can_merge || !merge_back(item)) {
@@ -174,17 +184,19 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
private void do_remove_item(Plugins.MetaConversationItem item) {
ConversationItemSkeleton? skeleton = item_item_skeletons[item];
- if (skeleton.items.size > 1) {
- skeleton.remove_meta_item(item);
- } else {
- widgets[item].destroy();
- widgets.unset(item);
- skeleton.destroy();
- item_skeletons.remove(skeleton);
- item_item_skeletons.unset(item);
+ if (skeleton != null) {
+ if (skeleton.items.size > 1) {
+ skeleton.remove_meta_item(item);
+ } else {
+ widgets[item].destroy();
+ widgets.unset(item);
+ skeleton.destroy();
+ item_skeletons.remove(skeleton);
+ item_item_skeletons.unset(item);
+ }
+ content_items.remove(item);
+ meta_items.remove(item);
}
- content_items.remove(item);
- meta_items.remove(item);
}
public void add_notification(Widget widget) {