瀏覽代碼

Move some `close` logic to the model

JC Brand 6 年之前
父節點
當前提交
84bde6e766
共有 2 個文件被更改,包括 9 次插入5 次删除
  1. 1 5
      src/converse-chatview.js
  2. 8 0
      src/headless/converse-chatboxes.js

+ 1 - 5
src/converse-chatview.js

@@ -1218,11 +1218,7 @@ converse.plugins.add('converse-chatview', {
                     this.setChatState(_converse.INACTIVE);
                     this.model.sendChatState();
                 }
-                try {
-                    this.model.destroy();
-                } catch (e) {
-                    _converse.log(e, Strophe.LogLevel.ERROR);
-                }
+                this.model.close();
                 this.remove();
                 /**
                  * Triggered once a chatbox has been closed.

+ 8 - 0
src/headless/converse-chatboxes.js

@@ -325,6 +325,14 @@ converse.plugins.add('converse-chatboxes', {
                 });
             },
 
+            close () {
+                try {
+                    this.destroy();
+                } catch (e) {
+                    _converse.log(e, Strophe.LogLevel.ERROR);
+                }
+            },
+
             validate (attrs, options) {
                 const { _converse } = this.__super__;
                 if (!attrs.jid) {