muc: only create view once model has finished initialization
This commit is contained in:
parent
9965a93291
commit
4b3d427cff
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user