diff --git a/spec/bookmarks.js b/spec/bookmarks.js index 9485adcea..ce736458e 100644 --- a/spec/bookmarks.js +++ b/spec/bookmarks.js @@ -17,8 +17,8 @@ describe("A chat room", function () { it("can be bookmarked", mock.initConverse( - ['rosterGroupsFetched', 'emojisInitialized'], {}, - async function (done, _converse) { + ['rosterGroupsFetched', 'emojisInitialized'], {}, + async function (done, _converse) { await test_utils.waitUntilDiscoConfirmed( _converse, _converse.bare_jid, diff --git a/src/converse-muc-views.js b/src/converse-muc-views.js index d5cbd463a..1d2a61f33 100644 --- a/src/converse-muc-views.js +++ b/src/converse-muc-views.js @@ -616,15 +616,13 @@ converse.plugins.add('converse-muc-views', { /** - * The View of an open/ongoing groupchat conversation + * Backbone.NativeView which renders a groupchat, based upon + * { @link _converse.ChatBoxView } for normal one-on-one chat boxes. * @class * @namespace _converse.ChatRoomView * @memberOf _converse */ _converse.ChatRoomView = _converse.ChatBoxView.extend({ - /* Backbone.NativeView which renders a groupchat, based upon the view - * for normal one-on-one chat boxes. - */ length: 300, tagName: 'div', className: 'chatbox chatroom hidden', @@ -700,6 +698,9 @@ converse.plugins.add('converse-muc-views', { if (this.model.get('connection_status') !== converse.ROOMSTATUS.ENTERED) { this.showSpinner(); } + if (!this.model.get('hidden')) { + this.show(); + } return this; }, @@ -2151,13 +2152,14 @@ converse.plugins.add('converse-muc-views', { } _converse.chatboxviews.delegate('click', 'a.open-chatroom', openChatRoomFromURIClicked); - function addView (model) { + async function addView (model) { const views = _converse.chatboxviews; if (!views.get(model.get('id')) && model.get('type') === _converse.CHATROOMS_TYPE && model.isValid() ) { - return views.add(model.get('id'), new _converse.ChatRoomView({'model': model})); + await model.initialized; + return views.add(model.get('id'), new _converse.ChatRoomView({model})); } } _converse.chatboxes.on('add', addView); diff --git a/src/headless/converse-muc.js b/src/headless/converse-muc.js index 14971ff5b..6a28e90de 100644 --- a/src/headless/converse-muc.js +++ b/src/headless/converse-muc.js @@ -378,6 +378,7 @@ converse.plugins.add('converse-muc', { }, async initialize() { + this.initialized = u.getResolveablePromise(); this.setVCard(); this.set('box_id', `box-${btoa(this.get('jid'))}`); @@ -391,6 +392,7 @@ converse.plugins.add('converse-muc', { await this.initOccupants(); await this.fetchMessages(); this.enterRoom(); + this.initialized.resolve(); }, async setVCard () {