Jelajahi Sumber

Bugfix. Controlbox closed state not remembered

in overlay view mode.

Also refactored a bit to put the method, which determines whether a
chatbox may be shown, on the chatbox itself.
JC Brand 6 tahun lalu
induk
melakukan
4eb6df92c6

+ 26 - 28
dist/converse.js

@@ -48767,10 +48767,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_3__["default"].plugins
           view.close();
           view.close();
         });
         });
         return this;
         return this;
-      },
-
-      chatBoxMayBeShown(chatbox) {
-        return this.model.chatBoxMayBeShown(chatbox);
       }
       }
 
 
     });
     });
@@ -50493,10 +50489,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
         } else {
         } else {
           return this.__super__.model.apply(this, arguments);
           return this.__super__.model.apply(this, arguments);
         }
         }
-      },
-
-      chatBoxMayBeShown(chatbox) {
-        return this.__super__.chatBoxMayBeShown.apply(this, arguments) && chatbox.get('id') !== 'controlbox';
       }
       }
 
 
     },
     },
@@ -50547,6 +50539,10 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_5__["default"].plugins
         return this.__super__.validate.apply(this, arguments);
         return this.__super__.validate.apply(this, arguments);
       },
       },
 
 
+      mayBeShown() {
+        return this.__super__.mayBeShown.apply(this, arguments) && this.get('id') !== 'controlbox';
+      },
+
       initialize() {
       initialize() {
         if (this.get('id') === 'controlbox') {
         if (this.get('id') === 'controlbox') {
           this.set({
           this.set({
@@ -52522,6 +52518,10 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
           'minimized': true,
           'minimized': true,
           'time_minimized': moment().format()
           'time_minimized': moment().format()
         });
         });
+      },
+
+      mayBeShown() {
+        return this.__super__.mayBeShown.apply(this, arguments) && !this.get('minimized');
       }
       }
 
 
     },
     },
@@ -52697,12 +52697,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
         return div.innerHTML;
         return div.innerHTML;
       }
       }
 
 
-    },
-    ChatBoxes: {
-      chatBoxMayBeShown(chatbox) {
-        return this.__super__.chatBoxMayBeShown.apply(this, arguments) && !chatbox.get('minimized');
-      }
-
     },
     },
     ChatBoxViews: {
     ChatBoxViews: {
       getChatBoxWidth(view) {
       getChatBoxWidth(view) {
@@ -60349,27 +60343,29 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
     // relevant objects or classes.
     // relevant objects or classes.
     //
     //
     // new functions which don't exist yet can also be added.
     // new functions which don't exist yet can also be added.
-    ChatBoxes: {
-      chatBoxMayBeShown(chatbox) {
+    ChatBox: {
+      mayBeShown() {
         const _converse = this.__super__._converse;
         const _converse = this.__super__._converse;
 
 
-        if (chatbox.get('id') === 'controlbox') {
-          return true;
-        }
-
         if (_converse.isUniView()) {
         if (_converse.isUniView()) {
+          if (this.get('id') === 'controlbox') {
+            return true;
+          }
+
           const any_chats_visible = _converse.chatboxes.filter(cb => cb.get('id') != 'controlbox').filter(cb => !cb.get('hidden')).length > 0;
           const any_chats_visible = _converse.chatboxes.filter(cb => cb.get('id') != 'controlbox').filter(cb => !cb.get('hidden')).length > 0;
 
 
           if (any_chats_visible) {
           if (any_chats_visible) {
-            return !chatbox.get('hidden');
+            return !this.get('hidden');
           } else {
           } else {
             return true;
             return true;
           }
           }
         } else {
         } else {
-          return this.__super__.chatBoxMayBeShown.apply(this, arguments);
+          return this.__super__.mayBeShown.apply(this, arguments);
         }
         }
-      },
+      }
 
 
+    },
+    ChatBoxes: {
       createChatBox(jid, attrs) {
       createChatBox(jid, attrs) {
         /* Make sure new chat boxes are hidden by default. */
         /* Make sure new chat boxes are hidden by default. */
         const _converse = this.__super__._converse;
         const _converse = this.__super__._converse;
@@ -62615,6 +62611,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
         return attrs;
         return attrs;
       },
       },
 
 
+      mayBeShown() {
+        return true;
+      },
+
       isHidden() {
       isHidden() {
         /* Returns a boolean to indicate whether a newly received
         /* Returns a boolean to indicate whether a newly received
          * message will be visible to the user or not.
          * message will be visible to the user or not.
@@ -62687,14 +62687,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
         }, null, 'message', 'error');
         }, null, 'message', 'error');
       },
       },
 
 
-      chatBoxMayBeShown(chatbox) {
-        return true;
-      },
-
       onChatBoxesFetched(collection) {
       onChatBoxesFetched(collection) {
         /* Show chat boxes upon receiving them from sessionStorage */
         /* Show chat boxes upon receiving them from sessionStorage */
         collection.each(chatbox => {
         collection.each(chatbox => {
-          if (this.chatBoxMayBeShown(chatbox)) {
+          if (chatbox.mayBeShown()) {
             chatbox.trigger('show');
             chatbox.trigger('show');
           }
           }
         });
         });
@@ -62753,6 +62749,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
         } else {
         } else {
           // An error message without id likely means that we
           // An error message without id likely means that we
           // sent a message without id (which shouldn't happen).
           // sent a message without id (which shouldn't happen).
+          _converse.log('Received an error message without id attribute!', Strophe.LogLevel.ERROR);
+
           _converse.log(message, Strophe.LogLevel.ERROR);
           _converse.log(message, Strophe.LogLevel.ERROR);
         }
         }
 
 

+ 0 - 4
src/converse-chatboxviews.js

@@ -145,10 +145,6 @@ converse.plugins.add('converse-chatboxviews', {
                  */
                  */
                 this.each(function (view) { view.close(); });
                 this.each(function (view) { view.close(); });
                 return this;
                 return this;
-            },
-
-            chatBoxMayBeShown (chatbox) {
-                return this.model.chatBoxMayBeShown(chatbox);
             }
             }
         });
         });
 
 

+ 6 - 6
src/converse-controlbox.js

@@ -92,12 +92,7 @@ converse.plugins.add('converse-controlbox', {
                 } else {
                 } else {
                     return this.__super__.model.apply(this, arguments);
                     return this.__super__.model.apply(this, arguments);
                 }
                 }
-            },
-
-            chatBoxMayBeShown (chatbox) {
-                return this.__super__.chatBoxMayBeShown.apply(this, arguments) &&
-                       chatbox.get('id') !== 'controlbox';
-            },
+            }
         },
         },
 
 
         ChatBoxViews: {
         ChatBoxViews: {
@@ -143,6 +138,11 @@ converse.plugins.add('converse-controlbox', {
                 return this.__super__.validate.apply(this, arguments);
                 return this.__super__.validate.apply(this, arguments);
             },
             },
 
 
+            mayBeShown () {
+                return this.__super__.mayBeShown.apply(this, arguments) &&
+                       this.get('id') !== 'controlbox';
+            },
+
             initialize () {
             initialize () {
                 if (this.get('id') === 'controlbox') {
                 if (this.get('id') === 'controlbox') {
                     this.set({'time_opened': moment(0).valueOf()});
                     this.set({'time_opened': moment(0).valueOf()});

+ 5 - 7
src/converse-minimize.js

@@ -68,6 +68,11 @@ converse.plugins.add('converse-minimize', {
                     'time_minimized': moment().format()
                     'time_minimized': moment().format()
                 });
                 });
             },
             },
+
+            mayBeShown () {
+                return this.__super__.mayBeShown.apply(this, arguments) &&
+                       !this.get('minimized');
+            }
         },
         },
 
 
         ChatBoxView: {
         ChatBoxView: {
@@ -219,13 +224,6 @@ converse.plugins.add('converse-minimize', {
             }
             }
         },
         },
 
 
-        ChatBoxes: {
-            chatBoxMayBeShown (chatbox) {
-                return this.__super__.chatBoxMayBeShown.apply(this, arguments) &&
-                       !chatbox.get('minimized');
-            },
-        },
-
         ChatBoxViews: {
         ChatBoxViews: {
             getChatBoxWidth (view) {
             getChatBoxWidth (view) {
                 if (!view.model.get('minimized') && u.isVisible(view.el)) {
                 if (!view.model.get('minimized') && u.isVisible(view.el)) {

+ 10 - 8
src/converse-singleton.js

@@ -43,28 +43,30 @@ converse.plugins.add('converse-singleton', {
         // relevant objects or classes.
         // relevant objects or classes.
         //
         //
         // new functions which don't exist yet can also be added.
         // new functions which don't exist yet can also be added.
-        ChatBoxes: {
 
 
-            chatBoxMayBeShown (chatbox) {
+        ChatBox: {
+            mayBeShown () {
                 const { _converse } = this.__super__;
                 const { _converse } = this.__super__;
-                if (chatbox.get('id') === 'controlbox') {
-                    return true;
-                }
                 if (_converse.isUniView()) {
                 if (_converse.isUniView()) {
+                    if (this.get('id') === 'controlbox') {
+                        return true;
+                    }
                     const any_chats_visible = _converse.chatboxes
                     const any_chats_visible = _converse.chatboxes
                         .filter(cb => cb.get('id') != 'controlbox')
                         .filter(cb => cb.get('id') != 'controlbox')
                         .filter(cb => !cb.get('hidden')).length > 0;
                         .filter(cb => !cb.get('hidden')).length > 0;
 
 
                     if (any_chats_visible) {
                     if (any_chats_visible) {
-                        return !chatbox.get('hidden');
+                        return !this.get('hidden');
                     } else {
                     } else {
                         return true;
                         return true;
                     }
                     }
                 } else {
                 } else {
-                    return this.__super__.chatBoxMayBeShown.apply(this, arguments);
+                    return this.__super__.mayBeShown.apply(this, arguments);
                 }
                 }
-            },
+            }
+        },
 
 
+        ChatBoxes: {
             createChatBox (jid, attrs) {
             createChatBox (jid, attrs) {
                 /* Make sure new chat boxes are hidden by default. */
                 /* Make sure new chat boxes are hidden by default. */
                 const { _converse } = this.__super__;
                 const { _converse } = this.__super__;

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

@@ -776,6 +776,10 @@ converse.plugins.add('converse-chatboxes', {
                 return attrs;
                 return attrs;
             },
             },
 
 
+            mayBeShown () {
+                return true;
+            },
+
             isHidden () {
             isHidden () {
                 /* Returns a boolean to indicate whether a newly received
                 /* Returns a boolean to indicate whether a newly received
                  * message will be visible to the user or not.
                  * message will be visible to the user or not.
@@ -840,14 +844,10 @@ converse.plugins.add('converse-chatboxes', {
                 }, null, 'message', 'error');
                 }, null, 'message', 'error');
             },
             },
 
 
-            chatBoxMayBeShown (chatbox) {
-                return true;
-            },
-
             onChatBoxesFetched (collection) {
             onChatBoxesFetched (collection) {
                 /* Show chat boxes upon receiving them from sessionStorage */
                 /* Show chat boxes upon receiving them from sessionStorage */
                 collection.each(chatbox => {
                 collection.each(chatbox => {
-                    if (this.chatBoxMayBeShown(chatbox)) {
+                    if (chatbox.mayBeShown()) {
                         chatbox.trigger('show');
                         chatbox.trigger('show');
                     }
                     }
                 });
                 });
@@ -898,6 +898,7 @@ converse.plugins.add('converse-chatboxes', {
                 } else {
                 } else {
                     // An error message without id likely means that we
                     // An error message without id likely means that we
                     // sent a message without id (which shouldn't happen).
                     // sent a message without id (which shouldn't happen).
+                    _converse.log('Received an error message without id attribute!', Strophe.LogLevel.ERROR);
                     _converse.log(message, Strophe.LogLevel.ERROR);
                     _converse.log(message, Strophe.LogLevel.ERROR);
                 }
                 }
                 const attrs = await chatbox.getMessageAttributesFromStanza(message, message);
                 const attrs = await chatbox.getMessageAttributesFromStanza(message, message);

+ 7 - 5
src/headless/dist/converse-headless.js

@@ -41123,6 +41123,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
         return attrs;
         return attrs;
       },
       },
 
 
+      mayBeShown() {
+        return true;
+      },
+
       isHidden() {
       isHidden() {
         /* Returns a boolean to indicate whether a newly received
         /* Returns a boolean to indicate whether a newly received
          * message will be visible to the user or not.
          * message will be visible to the user or not.
@@ -41195,14 +41199,10 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
         }, null, 'message', 'error');
         }, null, 'message', 'error');
       },
       },
 
 
-      chatBoxMayBeShown(chatbox) {
-        return true;
-      },
-
       onChatBoxesFetched(collection) {
       onChatBoxesFetched(collection) {
         /* Show chat boxes upon receiving them from sessionStorage */
         /* Show chat boxes upon receiving them from sessionStorage */
         collection.each(chatbox => {
         collection.each(chatbox => {
-          if (this.chatBoxMayBeShown(chatbox)) {
+          if (chatbox.mayBeShown()) {
             chatbox.trigger('show');
             chatbox.trigger('show');
           }
           }
         });
         });
@@ -41261,6 +41261,8 @@ _converse_core__WEBPACK_IMPORTED_MODULE_2__["default"].plugins.add('converse-cha
         } else {
         } else {
           // An error message without id likely means that we
           // An error message without id likely means that we
           // sent a message without id (which shouldn't happen).
           // sent a message without id (which shouldn't happen).
+          _converse.log('Received an error message without id attribute!', Strophe.LogLevel.ERROR);
+
           _converse.log(message, Strophe.LogLevel.ERROR);
           _converse.log(message, Strophe.LogLevel.ERROR);
         }
         }