From d025387ab95719ebfd7e41676c6f4138bc0afc44 Mon Sep 17 00:00:00 2001 From: bobufa Date: Fri, 3 Aug 2018 19:41:23 +0200 Subject: fix message filter in conversation view for first message --- .../ui/conversation_summary/conversation_view.vala | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'main') diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala index f9f0bef0..7fce6673 100644 --- a/main/src/ui/conversation_summary/conversation_view.vala +++ b/main/src/ui/conversation_summary/conversation_view.vala @@ -161,13 +161,15 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { } 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); + if (meta_items.size > 0) { + bool after_last = meta_items.last().sort_time.compare(item.sort_time) < 0; + bool within_range = meta_items.last().sort_time.compare(item.sort_time) > 0 && meta_items.first().sort_time.compare(item.sort_time) < 0; + bool accept = within_range || (at_current_content && after_last); + if (!accept) { + return; + } } + do_insert_item(item); } public void do_insert_item(Plugins.MetaConversationItem item) { @@ -359,8 +361,11 @@ public class ConversationView : Box, Plugins.ConversationItemCollection { private static int compare_meta_items(Plugins.MetaConversationItem a, Plugins.MetaConversationItem b) { int res = a.sort_time.compare(b.sort_time); if (res == 0) { - if (a.seccondary_sort_indicator < b.seccondary_sort_indicator) res = -1; - else if (a.seccondary_sort_indicator > b.seccondary_sort_indicator) res = 1; + if (a.seccondary_sort_indicator < b.seccondary_sort_indicator) { + res = -1; + } else if (a.seccondary_sort_indicator > b.seccondary_sort_indicator) { + res = 1; + } } return res; } -- cgit v1.2.3-70-g09d2