Move enterRoom method to the model

This commit is contained in:
JC Brand 2019-05-21 12:04:55 +02:00
parent 4c924a66df
commit 1269d53e02
2 changed files with 14 additions and 13 deletions

View File

@ -572,19 +572,6 @@ converse.plugins.add('converse-muc-views', {
this.createOccupantsView();
this.insertIntoDOM();
this.registerHandlers();
this.enterRoom();
},
async enterRoom () {
if (this.model.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
await this.model.getRoomFeatures();
if (!u.isPersistableModel(this.model)) {
// XXX: Happens during tests, nothing to do if this
// is a hanging chatbox (i.e. not in the collection anymore).
return;
}
this.model.join();
}
/**
* Triggered once a groupchat has been opened
* @event _converse#chatRoomOpened

View File

@ -218,8 +218,22 @@ converse.plugins.add('converse-muc', {
this.initOccupants();
this.registerHandlers();
this.initMessages();
this.enterRoom();
},
async enterRoom () {
if (this.get('connection_status') !== converse.ROOMSTATUS.ENTERED) {
await this.getRoomFeatures();
if (!u.isPersistableModel(this)) {
// XXX: Happens during tests, nothing to do if this
// is a hanging chatbox (i.e. not in the collection anymore).
return;
}
this.join();
}
},
async onConnectionStatusChanged () {
if (this.get('connection_status') === converse.ROOMSTATUS.ENTERED) {
this.occupants.fetchMembers();