diff options
author | lovetox <philipp@hoerist.com> | 2022-08-21 01:28:36 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2022-08-21 01:28:36 +0300 |
commit | 12669c512656b01180a2871f5a8f1b1e8b115687 (patch) | |
tree | 7210da00eaf386d04f6795ec7aa9dbbcfb556636 | |
parent | 18ac20841f531939e0ab8d1e25711be04a460dd6 (diff) |
fix: Don’t reset setting when closing single chat
- confirm_close_muc was reset to False whenever a single chat was closed
- Refactor code
-rw-r--r-- | gajim/gtk/chat_list_stack.py | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/gajim/gtk/chat_list_stack.py b/gajim/gtk/chat_list_stack.py index 117a9f197..02b61df4a 100644 --- a/gajim/gtk/chat_list_stack.py +++ b/gajim/gtk/chat_list_stack.py @@ -251,31 +251,38 @@ class ChatListStack(Gtk.Stack, EventHelper): chat_list = self._chat_lists[workspace_id] type_ = chat_list.get_chat_type(account, jid) - def _leave(is_checked: bool) -> None: - if is_checked: + def _leave(not_ask_again: bool) -> None: + if not_ask_again: app.settings.set('confirm_close_muc', False) + _remove() + def _remove() -> None: chat_list.remove_chat(account, jid, emit_unread=False) self.store_open_chats(workspace_id) self.emit('chat-removed', account, jid, type_) - if type_ == 'groupchat' and app.settings.get('confirm_close_muc'): - client = app.get_client(account) - contact = client.get_module('Contacts').get_group_chat_contact(jid) - ConfirmationCheckDialog( - _('Leave Group Chat'), - _('Are you sure you want to leave this group chat?'), - _('If you close this chat, you will leave ' - '"%s".') % contact.name, - _('_Do not ask me again'), - [DialogButton.make('Cancel'), - DialogButton.make('Accept', - text=_('_Leave'), - callback=_leave)], - transient_for=app.window).show() + if type_ != 'groupchat' or not app.settings.get('confirm_close_muc'): + _remove() return - _leave(True) + client = app.get_client(account) + contact = client.get_module('Contacts').get_group_chat_contact(jid) + + if contact.is_not_joined: + _remove() + return + + ConfirmationCheckDialog( + _('Leave Group Chat'), + _('Are you sure you want to leave this group chat?'), + _('If you close this chat, you will leave ' + '"%s".') % contact.name, + _('_Do not ask me again'), + [DialogButton.make('Cancel'), + DialogButton.make('Accept', + text=_('_Leave'), + callback=_leave)], + transient_for=app.window).show() def remove_chats_for_account(self, account: str) -> None: for workspace_id, chat_list in self._chat_lists.items(): |