Quellcode durchsuchen

Call trimChats when the window is resized.

Also fixed 2 bugs.

1. Instead of checking whether minimized chats toggle is visible, check whether
there ae aleady minimized chats (visuals might be delayed).
2. Don't call restore from removeChat. Chat gets restored earlier.
JC Brand vor 11 Jahren
Ursprung
Commit
190142a0b0
1 geänderte Dateien mit 10 neuen und 6 gelöschten Zeilen
  1. 10 6
      converse.js

+ 10 - 6
converse.js

@@ -521,12 +521,16 @@
                 this.resized_chatbox = null;
                 this.resized_chatbox = null;
             }, this));
             }, this));
 
 
-            $(window).on("blur focus", $.proxy(function(e) {
-                if ((this.windowState != e.type) && (e.type == 'focus')) {
+            $(window).on("blur focus", $.proxy(function (ev) {
+                if ((this.windowState != ev.type) && (ev.type == 'focus')) {
                     converse.clearMsgCounter();
                     converse.clearMsgCounter();
                 }
                 }
-                this.windowState = e.type;
+                this.windowState = ev.type;
             },this));
             },this));
+
+            $(window).on("resize", _.debounce($.proxy(function (ev) {
+                this.chatboxviews.trimChats();
+            },this), 200));
         };
         };
 
 
         this.onReconnected = function () {
         this.onReconnected = function () {
@@ -2547,9 +2551,9 @@
                 }
                 }
                 var controlbox_width = 0,
                 var controlbox_width = 0,
                     $minimized = converse.minimized_chats.$el,
                     $minimized = converse.minimized_chats.$el,
-                    minimized_width = $minimized.is(':visible') ? $minimized.outerWidth(true) : 0,
+                    minimized_width = _.contains(this.model.pluck('minimized'), true) ? $minimized.outerWidth(true) : 0,
                     boxes_width = newchat ? newchat.$el.outerWidth(true) : 0,
                     boxes_width = newchat ? newchat.$el.outerWidth(true) : 0,
-                    new_id = newchat ? newchat.model.get('id') : 0,
+                    new_id = newchat ? newchat.model.get('id') : null,
                     controlbox = this.get('controlbox');
                     controlbox = this.get('controlbox');
 
 
                 if (!controlbox || !controlbox.$el.is(':visible')) {
                 if (!controlbox || !controlbox.$el.is(':visible')) {
@@ -2734,7 +2738,7 @@
             },
             },
 
 
             removeChat: function (item) {
             removeChat: function (item) {
-                this.remove(item.get('id')).restore();
+                this.remove(item.get('id'));
                 this.chats_toggle.set({'num_minimized': this.keys().length});
                 this.chats_toggle.set({'num_minimized': this.keys().length});
                 this.render();
                 this.render();
             }
             }