浏览代码

Move `enterRoom` method to the model

JC Brand 6 年之前
父节点
当前提交
1269d53e02
共有 2 个文件被更改,包括 14 次插入13 次删除
  1. 0 13
      src/converse-muc-views.js
  2. 14 0
      src/headless/converse-muc.js

+ 0 - 13
src/converse-muc-views.js

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

+ 14 - 0
src/headless/converse-muc.js

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