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

Don't show "new messages" indicator for archived messages

JC Brand 9 жил өмнө
parent
commit
2b88db812d

+ 2 - 1
docs/CHANGES.md

@@ -8,8 +8,9 @@
 - Chat bot messages don't appear when they have the same ids as their commands.
   [jcbrand]
 - Updated onDisconnected method to fire disconnected event even if `auto_reconnect = false`. [kamranzafar]
+- Bugfix: MAM messages weren't being fetched oldest first. [jcbrand]
 - #553 Add processing hints to OTR messages [jcbrand]
-- #553 Add processing hints to chat state notifications [jcbrand]
+- Add processing hints to chat state notifications [jcbrand]
 
 ## 1.0.2 (2016-05-24)
 

+ 4 - 1
src/converse-chatview.js

@@ -335,7 +335,10 @@
                         if (converse.windowState === 'blur' || this.model.get('scrolled', true)) {
                             converse.incrementMsgCounter();
                         }
-                        if (this.model.get('scrolled', true)) {
+                        if (!message.get('archive_id') && this.model.get('scrolled', true)) {
+                            // Show "new messages" indicator if we're scrolled
+                            // up, but only if the new message is not a MAM
+                            // archived one.
                             this.$el.find('.new-msgs-indicator').removeClass('hidden');
                         }
                     } else {

+ 7 - 3
src/converse-core.js

@@ -1167,7 +1167,7 @@
                 });
             },
 
-            createMessage: function ($message, $delay, original_stanza) {
+            getMessageAttributes: function ($message, $delay, original_stanza) {
                 $delay = $delay || $message.find('delay');
                 var body = $message.children('body').text(),
                     delayed = $delay.length > 0,
@@ -1199,7 +1199,7 @@
                 } else {
                     sender = 'them';
                 }
-                return this.messages.create({
+                return {
                     chat_state: chat_state,
                     delayed: delayed,
                     fullname: fullname,
@@ -1207,7 +1207,11 @@
                     msgid: $message.attr('id'),
                     sender: sender,
                     time: time
-                });
+                };
+            },
+
+            createMessage: function ($message, $delay, original_stanza) {
+                return this.messages.create(this.getMessageAttributes.apply(this, arguments));
             }
         });
 

+ 4 - 6
src/converse-mam.js

@@ -49,12 +49,10 @@
             },
 
             ChatBox: {
-                createMessage: function ($message, $delay, original_stanza) {
-                    var message = this._super.createMessage.apply(this, arguments);
-                    message.save({
-                        archive_id: $(original_stanza).find('result[xmlns="'+Strophe.NS.MAM+'"]').attr('id')
-                    });
-                    return message;
+                getMessageAttributes: function ($message, $delay, original_stanza) {
+                    var attrs = this._super.getMessageAttributes.apply(this, arguments);
+                    attrs.archive_id = $(original_stanza).find('result[xmlns="'+Strophe.NS.MAM+'"]').attr('id');
+                    return attrs;
                 }
             },