Prechádzať zdrojové kódy

bookmarks: Don't autojoin rooms prematurely

by first waiting until chatboxes have been fetched as well.
JC Brand 8 rokov pred
rodič
commit
3835ab7af6

+ 1 - 0
docs/source/developer_api.rst

@@ -189,6 +189,7 @@ Converse.js has the following promises:
 * rosterGroupsFetched
 * rosterInitialized
 * statusInitialized
+* roomsPanelRendered (only via the `converse-muc` plugin)
 
 Below is an example from `converse-muc.js <https://github.com/jcbrand/converse.js/blob/master/src/converse-muc.js>`_
 where the `rosterContactsFetched` promise is waited on. The method

+ 2 - 1
src/converse-bookmarks.js

@@ -470,7 +470,8 @@
                 });
                 _converse.emit('bookmarksInitialized');
             };
-            _converse.on('roomsPanelRendered', initBookmarks);
+            $.when(_converse.api.waitUntil('chatBoxesFetched'),
+                   _converse.api.waitUntil('roomsPanelRendered')).then(initBookmarks);
 
             var afterReconnection = function () {
                 if (!_converse.allow_bookmarks) {

+ 5 - 1
src/converse-muc.js

@@ -319,6 +319,10 @@
                 },
             });
 
+            _.extend(_converse.promises, {
+                'roomsPanelRendered': new $.Deferred()
+            });
+
             _converse.createChatRoom = function (settings) {
                 /* Creates a new chat room, making sure that certain attributes
                  * are correct, for example that the "type" is set to
@@ -385,7 +389,7 @@
                         });
                     } else {
                         this.fetchMessages();
-                        _converse.emit('chatRoomOpened', that);
+                        _converse.emit('chatRoomOpened', this);
                     }
                 },