2
0
Эх сурвалжийг харах

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 11 жил өмнө
parent
commit
190142a0b0
1 өөрчлөгдсөн 10 нэмэгдсэн , 6 устгасан
  1. 10 6
      converse.js

+ 10 - 6
converse.js

@@ -521,12 +521,16 @@
                 this.resized_chatbox = null;
             }, 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();
                 }
-                this.windowState = e.type;
+                this.windowState = ev.type;
             },this));
+
+            $(window).on("resize", _.debounce($.proxy(function (ev) {
+                this.chatboxviews.trimChats();
+            },this), 200));
         };
 
         this.onReconnected = function () {
@@ -2547,9 +2551,9 @@
                 }
                 var controlbox_width = 0,
                     $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,
-                    new_id = newchat ? newchat.model.get('id') : 0,
+                    new_id = newchat ? newchat.model.get('id') : null,
                     controlbox = this.get('controlbox');
 
                 if (!controlbox || !controlbox.$el.is(':visible')) {
@@ -2734,7 +2738,7 @@
             },
 
             removeChat: function (item) {
-                this.remove(item.get('id')).restore();
+                this.remove(item.get('id'));
                 this.chats_toggle.set({'num_minimized': this.keys().length});
                 this.render();
             }