muc: only create view once model has finished initialization

This commit is contained in:
JC Brand 2019-11-08 09:49:58 +01:00
parent 9965a93291
commit 4b3d427cff
3 changed files with 12 additions and 8 deletions

View File

@ -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);

View File

@ -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 () {