Philipp Hörist pushed to branch master at gajim / gajim


Commits:
12669c51 by lovetox at 2022-08-21T00:28:36+02:00
fix: Don’t reset setting when closing single chat

- confirm_close_muc was reset to False whenever a single chat was closed
- Refactor code

- - - - -


1 changed file:

- gajim/gtk/chat_list_stack.py


Changes:

=====================================
gajim/gtk/chat_list_stack.py
=====================================
@@ -251,31 +251,38 @@ def remove_chat(self, workspace_id: str, account: str, 
jid: JID) -> None:
         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():



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/12669c512656b01180a2871f5a8f1b1e8b115687

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/12669c512656b01180a2871f5a8f1b1e8b115687
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
Commits@gajim.org
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to