浏览代码

converse-muc: `occupantAdded` promise has been removed

Also:

* converted two docstrings into JSDoc format
* Don't use `_.isNull`
JC Brand 5 年之前
父节点
当前提交
bcc73fe727
共有 3 个文件被更改,包括 17 次插入13 次删除
  1. 4 6
      src/converse-message-view.js
  2. 12 6
      src/headless/converse-chatboxes.js
  3. 1 1
      src/headless/converse-muc.js

+ 4 - 6
src/converse-message-view.js

@@ -111,12 +111,10 @@ converse.plugins.add('converse-message-view', {
                     });
                     });
                 }
                 }
 
 
-                if (this.model.occupantAdded) {
-                    this.model.occupantAdded.then(() => {
-                        this.model.occupant.on('change:role', this.debouncedRender, this);
-                        this.model.occupant.on('change:affiliation', this.debouncedRender, this);
-                        this.debouncedRender();
-                    });
+                if (this.model.occupant) {
+                    this.model.occupant.on('change:role', this.debouncedRender, this);
+                    this.model.occupant.on('change:affiliation', this.debouncedRender, this);
+                    this.debouncedRender();
                 }
                 }
 
 
                 this.model.on('change', this.onChanged, this);
                 this.model.on('change', this.onChanged, this);

+ 12 - 6
src/headless/converse-chatboxes.js

@@ -1010,20 +1010,26 @@ converse.plugins.add('converse-chatboxes', {
                 return this.trigger("show");
                 return this.trigger("show");
             },
             },
 
 
+            /**
+             * Indicates whether the chat is hidden and therefore
+             * whether a newly received message will be visible
+             * to the user or not.
+             * @returns {boolean}
+             */
             isHidden () {
             isHidden () {
-                /* Returns a boolean to indicate whether a newly received
-                 * message will be visible to the user or not.
-                 */
                 return this.get('hidden') ||
                 return this.get('hidden') ||
                     this.get('minimized') ||
                     this.get('minimized') ||
                     this.isScrolledUp() ||
                     this.isScrolledUp() ||
                     _converse.windowState === 'hidden';
                     _converse.windowState === 'hidden';
             },
             },
 
 
+            /**
+             * Given a newly received {@link _converse.Message} instance,
+             * update the unread counter if necessary.
+             * @private
+             * @param {_converse.Message} message
+             */
             incrementUnreadMsgCounter (message) {
             incrementUnreadMsgCounter (message) {
-                /* Given a newly received message, update the unread counter if
-                 * necessary.
-                 */
                 if (!message || !message.get('message')) {
                 if (!message || !message.get('message')) {
                     return;
                     return;
                 }
                 }

+ 1 - 1
src/headless/converse-muc.js

@@ -1602,7 +1602,7 @@ converse.plugins.add('converse-muc', {
              * @param { XMLElement } stanza: The presence stanza received
              * @param { XMLElement } stanza: The presence stanza received
              */
              */
             createInfoMessages (stanza) {
             createInfoMessages (stanza) {
-                const is_self = !_.isNull(stanza.querySelector("status[code='110']"));
+                const is_self = stanza.querySelector("status[code='110']") !== null;
                 const x = sizzle(`x[xmlns="${Strophe.NS.MUC_USER}"]`, stanza).pop();
                 const x = sizzle(`x[xmlns="${Strophe.NS.MUC_USER}"]`, stanza).pop();
                 if (!x) {
                 if (!x) {
                     return;
                     return;