diff options
4 files changed, 25 insertions, 17 deletions
diff --git a/libdino/src/service/conversation_manager.vala b/libdino/src/service/conversation_manager.vala index c473ea77..3b48f154 100644 --- a/libdino/src/service/conversation_manager.vala +++ b/libdino/src/service/conversation_manager.vala @@ -126,6 +126,8 @@ public class ConversationManager : StreamInteractionModule, Object { } public void close_conversation(Conversation conversation) { + if (!conversation.active) return; + conversation.active = false; conversation_deactivated(conversation); } diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala index 62d089e7..ab461701 100644 --- a/libdino/src/service/muc_manager.vala +++ b/libdino/src/service/muc_manager.vala @@ -33,6 +33,11 @@ public class MucManager : StreamInteractionModule, Object { stream_interactor.account_added.connect(on_account_added); stream_interactor.stream_negotiated.connect(on_stream_negotiated); stream_interactor.get_module(MessageProcessor.IDENTITY).received_pipeline.connect(received_message_listener); + stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect((conversation) => { + if (conversation.type_ == Conversation.Type.GROUPCHAT) { + part(conversation.account, conversation.counterpart); + } + }); } public async Muc.JoinResult? join(Account account, Jid jid, string? nick, string? password) { diff --git a/main/src/ui/conversation_selector/conversation_selector.vala b/main/src/ui/conversation_selector/conversation_selector.vala index 869f6403..9276148b 100644 --- a/main/src/ui/conversation_selector/conversation_selector.vala +++ b/main/src/ui/conversation_selector/conversation_selector.vala @@ -71,7 +71,6 @@ public class ConversationSelector : ListBox { row = new ConversationSelectorRow(stream_interactor, conversation); rows[conversation] = row; add(row); - row.closed.connect(() => { select_fallback_conversation(conversation); }); row.main_revealer.set_reveal_child(true); } invalidate_sort(); @@ -91,9 +90,10 @@ public class ConversationSelector : ListBox { } } - private void remove_conversation(Conversation conversation) { + private async void remove_conversation(Conversation conversation) { select_fallback_conversation(conversation); if (rows.has_key(conversation)) { + yield rows[conversation].colapse(); remove(rows[conversation]); rows.unset(conversation); } 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) { |