Kaynağa Gözat

Start fixing message count bugs

JC Brand 11 yıl önce
ebeveyn
işleme
0d3c101cbf
2 değiştirilmiş dosya ile 12 ekleme ve 8 silme
  1. 4 2
      converse.js
  2. 8 6
      spec/chatbox.js

+ 4 - 2
converse.js

@@ -1463,8 +1463,10 @@
             },
 
             scrollDown: function () {
-                var $content = this.$el.find('.chat-content');
-                $content.scrollTop($content[0].scrollHeight);
+                var $content = this.$('.chat-content');
+                if ($content.is(':visible')) {
+                    $content.scrollTop($content[0].scrollHeight);
+                }
                 return this;
             }
         });

+ 8 - 6
spec/chatbox.js

@@ -464,13 +464,13 @@
                     runs(function () {
                         utils.openChatBoxFor(contact_jid);
                     });
-                    waits(250);
+                    waits(50);
                     runs(function () {
                         var chatview = converse.chatboxviews.get(contact_jid);
                         expect(chatview.model.get('minimized')).toBeFalsy();
                         chatview.$el.find('.toggle-chatbox-button').click();
                     });
-                    waits(250);
+                    waits(50);
                     runs($.proxy(function () {
                         var chatview = this.chatboxviews.get(contact_jid);
                         expect(chatview.model.get('minimized')).toBeTruthy();
@@ -486,10 +486,12 @@
                         this.chatboxes.onMessage(msg);
                         expect(this.emit).toHaveBeenCalledWith('onMessage', msg);
                     }, converse));
-                    waits(250);
+                    waits(50);
                     runs($.proxy(function () {
                         var chatview = this.chatboxviews.get(contact_jid);
-                        var $count = chatview.$el.find('.chat-head-message-count');
+                        var trimmed_chatboxes = this.chatboxviews.trimmed_chatboxes_view;
+                        var trimmedview = trimmed_chatboxes.get(contact_jid);
+                        var $count = trimmedview.$el.find('.chat-head-message-count');
                         expect(chatview.model.get('minimized')).toBeTruthy();
                         expect($count.is(':visible')).toBeTruthy();
                         expect($count.data('count')).toBe(1);
@@ -504,7 +506,7 @@
                             .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree()
                         );
                     }, converse));
-                    waits(100);
+                    waits(50);
                     runs($.proxy(function () {
                         var chatview = this.chatboxviews.get(contact_jid);
                         var $count = chatview.$el.find('.chat-head-message-count');
@@ -514,7 +516,7 @@
                         expect($count.html()).toBe('2');
                         chatview.$el.find('.toggle-chatbox-button').click();
                     }, converse));
-                    waits(250);
+                    waits(50);
                     runs($.proxy(function () {
                         var chatview = this.chatboxviews.get(contact_jid);
                         var $count = chatview.$el.find('.chat-head-message-count');