Commit 3835ab7a authored by JC Brand's avatar JC Brand

bookmarks: Don't autojoin rooms prematurely

by first waiting until chatboxes have been fetched as well.
parent d81d62f9
...@@ -189,6 +189,7 @@ Converse.js has the following promises: ...@@ -189,6 +189,7 @@ Converse.js has the following promises:
* rosterGroupsFetched * rosterGroupsFetched
* rosterInitialized * rosterInitialized
* statusInitialized * 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>`_ 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 where the `rosterContactsFetched` promise is waited on. The method
......
...@@ -470,7 +470,8 @@ ...@@ -470,7 +470,8 @@
}); });
_converse.emit('bookmarksInitialized'); _converse.emit('bookmarksInitialized');
}; };
_converse.on('roomsPanelRendered', initBookmarks); $.when(_converse.api.waitUntil('chatBoxesFetched'),
_converse.api.waitUntil('roomsPanelRendered')).then(initBookmarks);
var afterReconnection = function () { var afterReconnection = function () {
if (!_converse.allow_bookmarks) { if (!_converse.allow_bookmarks) {
......
...@@ -319,6 +319,10 @@ ...@@ -319,6 +319,10 @@
}, },
}); });
_.extend(_converse.promises, {
'roomsPanelRendered': new $.Deferred()
});
_converse.createChatRoom = function (settings) { _converse.createChatRoom = function (settings) {
/* Creates a new chat room, making sure that certain attributes /* Creates a new chat room, making sure that certain attributes
* are correct, for example that the "type" is set to * are correct, for example that the "type" is set to
...@@ -385,7 +389,7 @@ ...@@ -385,7 +389,7 @@
}); });
} else { } else {
this.fetchMessages(); this.fetchMessages();
_converse.emit('chatRoomOpened', that); _converse.emit('chatRoomOpened', this);
} }
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment