[Git][gajim/gajim][master] Fix destroying a MUC

Philipp Hörist gitlab at dev.gajim.org
Sat Jan 19 23:06:24 CET 2019


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


Commits:
46707606 by Philipp Hörist at 2019-01-19T22:05:36Z
Fix destroying a MUC

- Only close the tab if we initiated the destruction

- - - - -


4 changed files:

- gajim/common/modules/bookmarks.py
- gajim/common/modules/muc.py
- gajim/groupchat_control.py
- gajim/gtk/bookmarks.py


Changes:

=====================================
gajim/common/modules/bookmarks.py
=====================================
@@ -286,6 +286,9 @@ class Bookmarks(AbstractPEPModule):
         else:
             self._private_store(storage_node)
 
+        app.nec.push_incoming_event(
+            NetworkEvent('bookmarks-received', account=self._account))
+
     def _pubsub_store(self, storage_node: nbxmpp.Node) -> None:
         self._con.get_module('PubSub').send_pb_publish(
             '', 'storage:bookmarks', storage_node, 'current',
@@ -344,8 +347,12 @@ class Bookmarks(AbstractPEPModule):
         }
 
         self.store_bookmarks()
-        app.nec.push_incoming_event(
-            NetworkEvent('bookmarks-received', account=self._account))
+
+    def remove(self, jid: str, publish: bool = True) -> None:
+        if self.bookmarks.pop(jid, None) is None:
+            return
+        if publish:
+            self.store_bookmarks()
 
     def get_name_from_bookmark(self, jid: str) -> str:
         fallback = jid.split('@')[0]
@@ -354,6 +361,9 @@ class Bookmarks(AbstractPEPModule):
         except KeyError:
             return fallback
 
+    def is_bookmark(self, jid: str) -> bool:
+        return jid in self.bookmarks
+
     def purge_pubsub_bookmarks(self) -> None:
         log.info('Purge/Delete Bookmarks on PubSub, '
                  'because publish options are not available')


=====================================
gajim/common/modules/muc.py
=====================================
@@ -84,7 +84,7 @@ class MUC:
             'cancel_config',
             'send_captcha',
             'decline',
-            'request_voice'
+            'request_voice',
             'destroy',
         ]
 


=====================================
gajim/groupchat_control.py
=====================================
@@ -182,6 +182,9 @@ class GroupchatControl(ChatControlBase):
         # if True, the room has mentioned us
         self.attention_flag = False
 
+        # True if we initiated room destruction
+        self._wait_for_destruction = False
+
         # sorted list of nicks who mentioned us (last at the end)
         self.attention_list = []
         self.nick_hits = []
@@ -651,14 +654,10 @@ class GroupchatControl(ChatControlBase):
                         _('Invalid group chat JID'),
                         _('The group chat JID has not allowed characters.'))
                     return
+
+            self._wait_for_destruction = True
             con = app.connections[self.account]
             con.get_module('MUC').destroy(self.room_jid, reason, jid)
-            con.get_module('Bookmarks').bookmarks.pop(self.room_jid, None)
-            con.get_module('Bookmarks').store_bookmarks()
-            gui_menu_builder.build_bookmark_menu(self.account)
-            self.force_non_minimizable = True
-            self.parent_win.remove_tab(self, self.parent_win.CLOSE_COMMAND)
-            self.force_non_minimizable = False
 
         # Ask for a reason
         DoubleInputDialog(_('Destroying %s') % '\u200E' + \
@@ -2227,6 +2226,14 @@ class GroupchatControl(ChatControlBase):
         self.autorejoin = False
         self.got_disconnected()
 
+        con = app.connections[self.account]
+        con.get_module('Bookmarks').remove(self.room_jid)
+
+        if self._wait_for_destruction:
+            self.force_non_minimizable = True
+            self.parent_win.remove_tab(self, self.parent_win.CLOSE_COMMAND)
+            self.force_non_minimizable = False
+
     def get_role_iter(self, role: str) -> Optional[Gtk.TreeIter]:
         try:
             ref = self._role_refs[role]


=====================================
gajim/gtk/bookmarks.py
=====================================
@@ -21,8 +21,6 @@ from gajim.common import app
 from gajim.common import helpers
 from gajim.common.i18n import _
 
-from gajim import gui_menu_builder
-
 from gajim.gtk.dialogs import ErrorDialog
 from gajim.gtk.util import get_builder
 
@@ -207,7 +205,6 @@ class ManageBookmarksWindow:
                 con.get_module('Bookmarks').bookmarks[jid] = bmdict
 
             con.get_module('Bookmarks').store_bookmarks()
-            gui_menu_builder.build_bookmark_menu(acct)
         self.window.destroy()
 
     def on_cancel_button_clicked(self, widget):



View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/46707606687671488314f947cf5eeaac1360c354

-- 
View it on GitLab: https://dev.gajim.org/gajim/gajim/commit/46707606687671488314f947cf5eeaac1360c354
You're receiving this email because of your account on dev.gajim.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gajim.org/pipermail/commits/attachments/20190119/a85c19a0/attachment-0001.html>


More information about the Commits mailing list