Fix messages being displayed for the wrong sender: Show avatar on lower message when inserting message between two others
fixes #641 fixes #639
This commit is contained in:
parent
8f0fe37402
commit
c6bdb1a4bc
|
@ -71,6 +71,7 @@ public class ConversationItemSkeleton : EventBox {
|
||||||
this.show_skeleton = true;
|
this.show_skeleton = true;
|
||||||
this.last_group_item = true;
|
this.last_group_item = true;
|
||||||
update_margin();
|
update_margin();
|
||||||
|
this.notify["show-skeleton"].connect(update_margin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update_time() {
|
public void update_time() {
|
||||||
|
|
|
@ -254,18 +254,21 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
|
||||||
main.reorder_child(insert, index);
|
main.reorder_child(insert, index);
|
||||||
|
|
||||||
if (lower_item != null) {
|
if (lower_item != null) {
|
||||||
ConversationItemSkeleton lower_skeleton = item_item_skeletons[lower_item];
|
if (can_merge(item, lower_item)) {
|
||||||
Plugins.MetaConversationItem lower_start_item = lower_skeleton.item;
|
ConversationItemSkeleton lower_skeleton = item_item_skeletons[lower_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)) {
|
|
||||||
item_skeleton.show_skeleton = false;
|
item_skeleton.show_skeleton = false;
|
||||||
lower_skeleton.last_group_item = 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 an item from the past was added, add everything between that item and the (post-)first present item
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
Dino.Application app = Dino.Application.get_default();
|
Dino.Application app = Dino.Application.get_default();
|
||||||
|
@ -282,6 +285,14 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
|
||||||
return insert;
|
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() {
|
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 (was_upper == null || scrolled.vadjustment.value > was_upper - was_page_size - 1) { // scrolled down or content smaller than page size
|
||||||
if (at_current_content) {
|
if (at_current_content) {
|
||||||
|
|
Loading…
Reference in a new issue