From 7f21f898e0ec6efe5a8cf66053150e9a20ade53e Mon Sep 17 00:00:00 2001 From: fiaxh Date: Wed, 15 Jan 2020 23:44:15 +0100 Subject: Fix ConversationRow closing if animations are disabled --- .../conversation_selector_row.vala | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'main/src/ui/conversation_selector/conversation_selector_row.vala') diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala index 421ebd75..705aad29 100644 --- a/main/src/ui/conversation_selector/conversation_selector_row.vala +++ b/main/src/ui/conversation_selector/conversation_selector_row.vala @@ -12,8 +12,6 @@ namespace Dino.Ui { [GtkTemplate (ui = "/im/dino/Dino/conversation_selector/conversation_row.ui")] public class ConversationSelectorRow : ListBoxRow { - public signal void closed(); - [GtkChild] protected AvatarImage image; [GtkChild] protected Label name_label; [GtkChild] protected Label time_label; @@ -51,9 +49,6 @@ public class ConversationSelectorRow : ListBoxRow { }); break; case Conversation.Type.GROUPCHAT: - closed.connect(() => { - stream_interactor.get_module(MucManager.IDENTITY).part(conversation.account, conversation.counterpart); - }); stream_interactor.get_module(MucManager.IDENTITY).room_name_set.connect((account, jid, room_name) => { if (conversation != null && conversation.counterpart.equals_bare(jid) && conversation.account.equals(account)) { update_name_label(); @@ -93,7 +88,9 @@ public class ConversationSelectorRow : ListBoxRow { }); last_content_item = stream_interactor.get_module(ContentItemStore.IDENTITY).get_latest(conversation); - x_button.clicked.connect(close_conversation); + x_button.clicked.connect(() => { + stream_interactor.get_module(ConversationManager.IDENTITY).close_conversation(conversation); + }); image.set_conversation(stream_interactor, conversation); conversation.notify["read-up-to"].connect(update_read); @@ -112,6 +109,19 @@ public class ConversationSelectorRow : ListBoxRow { update_read(); } + public async void colapse() { + main_revealer.set_transition_type(RevealerTransitionType.SLIDE_UP); + main_revealer.set_reveal_child(false); + + // Animations can be diabled (=> child_revealed immediately false). Wait for completion in case they're enabled. + if (main_revealer.child_revealed) { + main_revealer.notify["child-revealed"].connect(() => { + Idle.add(colapse.callback); + }); + yield; + } + } + protected void update_name_label() { name_label.label = Util.get_conversation_display_name(stream_interactor, conversation); } @@ -209,15 +219,6 @@ public class ConversationSelectorRow : ListBoxRow { return box; } - private void close_conversation() { - main_revealer.set_transition_type(RevealerTransitionType.SLIDE_UP); - main_revealer.set_reveal_child(false); - closed(); - main_revealer.notify["child-revealed"].connect(() => { - stream_interactor.get_module(ConversationManager.IDENTITY).close_conversation(conversation); - }); - } - public override void state_flags_changed(StateFlags flags) { StateFlags curr_flags = get_state_flags(); if ((curr_flags & StateFlags.PRELIGHT) != 0) { -- cgit v1.2.3-54-g00ecf