Parcourir la source

Improvement in when trimChats gets called

Don't call trimChats when the box is minimized or maximized, instead call it
only when the minimized chats toggle appears or disappears, since that's the
element that adds/removes space.

Also, a fix. 'onShow' has been renamed to 'onMaximized'
JC Brand il y a 9 ans
Parent
commit
d893d9782a
2 fichiers modifiés avec 3 ajouts et 13 suppressions
  1. 1 1
      src/converse-controlbox.js
  2. 2 12
      src/converse-core.js

+ 1 - 1
src/converse-controlbox.js

@@ -158,7 +158,7 @@
                 maximize: function () {
                     var chatboxviews = converse.chatboxviews;
                     // Restores a minimized chat box
-                    this.$el.insertAfter(chatboxviews.get("controlbox").$el).show('fast', this.onShow.bind(this));
+                    this.$el.insertAfter(chatboxviews.get("controlbox").$el).show('fast', this.onMaximized.bind(this));
                     return this;
                 }
             }

+ 2 - 12
src/converse-core.js

@@ -2411,16 +2411,6 @@
 
             initialize: function () {
                 this.model.on("add", this.onChatBoxAdded, this);
-                this.model.on("change:minimized", function (item) {
-                    if (item.get('minimized') === true) {
-                        /* When a chat is minimized in trimChats, trimChats needs to be
-                        * called again (in case the minimized chats toggle is newly shown).
-                        */
-                        this.trimChats();
-                    } else {
-                        this.trimChats(this.get(item.get('id')));
-                    }
-                }, this);
             },
 
             _ensureElement: function () {
@@ -2623,9 +2613,9 @@
 
             render: function () {
                 if (this.keys().length === 0) {
-                    this.$el.hide('fast');
+                    this.$el.hide('fast', converse.chatboxviews.trimChats.bind(converse.chatboxviews));
                 } else if (this.keys().length === 1) {
-                    this.$el.show('fast');
+                    this.$el.show('fast', converse.chatboxviews.trimChats.bind(converse.chatboxviews));
                 }
                 return this.$el;
             },