aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-11-13 17:42:47 +0100
committerfiaxh <git@lightrise.org>2019-11-17 17:33:24 +0100
commitc6bdb1a4bc109256b2a109940c640a8b2ad8f57f (patch)
tree73de1703822b7fb6d1059d54e52aae19a70458e1 /main/src/ui
parent8f0fe374023e937f6f3d17412d7f9f110791deac (diff)
downloaddino-c6bdb1a4bc109256b2a109940c640a8b2ad8f57f.tar.gz
dino-c6bdb1a4bc109256b2a109940c640a8b2ad8f57f.zip
Fix messages being displayed for the wrong sender: Show avatar on lower message when inserting message between two others
fixes #641 fixes #639
Diffstat (limited to 'main/src/ui')
-rw-r--r--main/src/ui/conversation_summary/conversation_item_skeleton.vala1
-rw-r--r--main/src/ui/conversation_summary/conversation_view.vala25
2 files changed, 19 insertions, 7 deletions
diff --git a/main/src/ui/conversation_summary/conversation_item_skeleton.vala b/main/src/ui/conversation_summary/conversation_item_skeleton.vala
index 182ec298..28551b01 100644
--- a/main/src/ui/conversation_summary/conversation_item_skeleton.vala
+++ b/main/src/ui/conversation_summary/conversation_item_skeleton.vala
@@ -71,6 +71,7 @@ public class ConversationItemSkeleton : EventBox {
this.show_skeleton = true;
this.last_group_item = true;
update_margin();
+ this.notify["show-skeleton"].connect(update_margin);
}
public void update_time() {
diff --git a/main/src/ui/conversation_summary/conversation_view.vala b/main/src/ui/conversation_summary/conversation_view.vala
index d73d012b..4c5d1ace 100644
--- a/main/src/ui/conversation_summary/conversation_view.vala
+++ b/main/src/ui/conversation_summary/conversation_view.vala
@@ -254,18 +254,21 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
main.reorder_child(insert, index);
if (lower_item != null) {
- ConversationItemSkeleton lower_skeleton = item_item_skeletons[lower_item];
- Plugins.MetaConversationItem lower_start_item = lower_skeleton.item;
- if (item.display_time != null && lower_start_item.display_time != null &&
- item.display_time.difference(lower_start_item.display_time) < TimeSpan.MINUTE &&
- lower_start_item.jid.equals(item.jid) &&
- lower_start_item.encryption == item.encryption &&
- (item.mark == Message.Marked.WONTSEND) == (lower_start_item.mark == Message.Marked.WONTSEND)) {
+ if (can_merge(item, lower_item)) {
+ ConversationItemSkeleton lower_skeleton = item_item_skeletons[lower_item];
item_skeleton.show_skeleton = false;
lower_skeleton.last_group_item = false;
}
}
+ Plugins.MetaConversationItem? upper_item = meta_items.higher(item);
+ if (upper_item != null) {
+ if (!can_merge(upper_item, item)) {
+ ConversationItemSkeleton upper_skeleton = item_item_skeletons[upper_item];
+ upper_skeleton.show_skeleton = true;
+ }
+ }
+
// If an item from the past was added, add everything between that item and the (post-)first present item
if (index == 0) {
Dino.Application app = Dino.Application.get_default();
@@ -282,6 +285,14 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
return insert;
}
+ private bool can_merge(Plugins.MetaConversationItem upper_item /*more recent, displayed below*/, Plugins.MetaConversationItem lower_item /*less recent, displayed above*/) {
+ return upper_item.display_time != null && lower_item.display_time != null &&
+ upper_item.display_time.difference(lower_item.display_time) < TimeSpan.MINUTE &&
+ upper_item.jid.equals(lower_item.jid) &&
+ upper_item.encryption == lower_item.encryption &&
+ (upper_item.mark == Message.Marked.WONTSEND) == (lower_item.mark == Message.Marked.WONTSEND);
+ }
+
private void on_upper_notify() {
if (was_upper == null || scrolled.vadjustment.value > was_upper - was_page_size - 1) { // scrolled down or content smaller than page size
if (at_current_content) {