fix message filter in conversation view for first message

This commit is contained in:
bobufa 2018-08-03 19:41:23 +02:00
parent ec25ecf202
commit d025387ab9

View file

@ -161,13 +161,15 @@ public class ConversationView : Box, Plugins.ConversationItemCollection {
} }
public void filter_insert_item(Plugins.MetaConversationItem item) { public void filter_insert_item(Plugins.MetaConversationItem item) {
print(@"$(meta_items.last().sort_time.compare(item.sort_time))\n"); if (meta_items.size > 0) {
print(@"$(meta_items.first().sort_time.compare(item.sort_time))\n"); bool after_last = meta_items.last().sort_time.compare(item.sort_time) < 0;
if (at_current_content && 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;
do_insert_item(item); bool accept = within_range || (at_current_content && after_last);
} else if (meta_items.last().sort_time.compare(item.sort_time) > 0 && meta_items.first().sort_time.compare(item.sort_time) < 0) { if (!accept) {
do_insert_item(item); return;
}
} }
do_insert_item(item);
} }
public void do_insert_item(Plugins.MetaConversationItem 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) { private static int compare_meta_items(Plugins.MetaConversationItem a, Plugins.MetaConversationItem b) {
int res = a.sort_time.compare(b.sort_time); int res = a.sort_time.compare(b.sort_time);
if (res == 0) { if (res == 0) {
if (a.seccondary_sort_indicator < b.seccondary_sort_indicator) res = -1; if (a.seccondary_sort_indicator < b.seccondary_sort_indicator) {
else if (a.seccondary_sort_indicator > b.seccondary_sort_indicator) res = 1; res = -1;
} else if (a.seccondary_sort_indicator > b.seccondary_sort_indicator) {
res = 1;
}
} }
return res; return res;
} }