Browse Source

2 bugfixes.

When a chat is minimized in trimChats, trimChats needs to be called again (in
case the minimized chats toggle is newly shown).

Debounce the "restore" method to avoid breakage due to double click.
JC Brand 11 năm trước cách đây
mục cha
commit
9c2b19c71d
1 tập tin đã thay đổi với 11 bổ sung7 xóa
  1. 11 7
      converse.js

+ 11 - 7
converse.js

@@ -1321,7 +1321,6 @@
 
 
             maximize: function () {
             maximize: function () {
                 // Restores a minimized chat box
                 // Restores a minimized chat box
-                this.model.trigger('maximized', this.model);
                 this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el).show('fast', $.proxy(function () {
                 this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el).show('fast', $.proxy(function () {
                     converse.refreshWebkit();
                     converse.refreshWebkit();
                     this.focus();
                     this.focus();
@@ -2490,8 +2489,12 @@
 
 
             initialize: function () {
             initialize: function () {
                 this.model.on("add", this.onChatAdded, this);
                 this.model.on("add", this.onChatAdded, this);
-                this.model.on("maximized", function (item) {
-                    this.trimChats(this.get(item.get('id')));
+                this.model.on("change:minimized", function (item) {
+                    if (item.get('minimized') === false) {
+                         this.trimChats(this.get(item.get('id')));
+                    } else {
+                         this.trimChats();
+                    }
                 }, this);
                 }, this);
             },
             },
 
 
@@ -2545,7 +2548,8 @@
                 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 = $minimized.is(':visible') ? $minimized.outerWidth(true) : 0,
-                    boxes_width = newchat.$el.outerWidth(true),
+                    boxes_width = newchat ? newchat.$el.outerWidth(true) : 0,
+                    new_id = newchat ? newchat.model.get('id') : 0,
                     controlbox = this.get('controlbox');
                     controlbox = this.get('controlbox');
 
 
                 if (!controlbox || !controlbox.$el.is(':visible')) {
                 if (!controlbox || !controlbox.$el.is(':visible')) {
@@ -2556,7 +2560,7 @@
 
 
                 _.each(this.getAll(), function (view) {
                 _.each(this.getAll(), function (view) {
                     var id = view.model.get('id');
                     var id = view.model.get('id');
-                    if (view.$el.is(':visible') && (id !== 'controlbox') && (id !== newchat.model.get('id'))) { 
+                    if ((id !== 'controlbox') && (id !== new_id) && (!view.model.get('minimized'))) {
                         boxes_width += view.$el.outerWidth(true);
                         boxes_width += view.$el.outerWidth(true);
                     }
                     }
                 });
                 });
@@ -2661,14 +2665,14 @@
                 return this;
                 return this;
             },
             },
 
 
-            restore: function (ev) {
+            restore: _.debounce(function (ev) {
                 if (ev && ev.preventDefault) {
                 if (ev && ev.preventDefault) {
                     ev.preventDefault();
                     ev.preventDefault();
                 }
                 }
                 this.$el.remove();
                 this.$el.remove();
                 this.model.maximize();
                 this.model.maximize();
                 return this;
                 return this;
-            }
+            }, 200)
         });
         });
 
 
         this.MinimizedChats = Backbone.Overview.extend({
         this.MinimizedChats = Backbone.Overview.extend({