Bugfix. Don't scroll down on archived messages

when already scrolled up.
This commit is contained in:
JC Brand 2017-06-14 19:18:14 +02:00
parent 0d22f5c33c
commit e1dace59ae
2 changed files with 14 additions and 8 deletions

View File

@ -419,16 +419,16 @@
handleTextMessage: function (message) { handleTextMessage: function (message) {
this.showMessage(_.clone(message.attributes)); this.showMessage(_.clone(message.attributes));
if (message.get('sender') !== 'me') { if (utils.isNewMessage(message) && message.get('sender') === 'me') {
if (!message.get('archive_id') && this.model.get('scrolled', true)) {
this.$el.find('.new-msgs-indicator').removeClass('hidden');
}
} else {
// We remove the "scrolled" flag so that the chat area // We remove the "scrolled" flag so that the chat area
// gets scrolled down. We always want to scroll down // gets scrolled down. We always want to scroll down
// when the user writes a message as opposed to when a // when the user writes a message as opposed to when a
// message is received. // message is received.
this.model.set('scrolled', false); this.model.set('scrolled', false);
} else {
if (utils.isNewMessage(message) && this.model.get('scrolled', true)) {
this.$el.find('.new-msgs-indicator').removeClass('hidden');
}
} }
if (this.shouldShowOnTextMessage()) { if (this.shouldShowOnTextMessage()) {
this.show(); this.show();

View File

@ -18,7 +18,9 @@
"tpl!form_captcha" "tpl!form_captcha"
], factory); ], factory);
}(this, function ( }(this, function (
$, sizzle, dummy, _, locales, moment, $, sizzle, dummy, _,
locales,
moment,
Strophe, Strophe,
tpl_field, tpl_field,
tpl_select_option, tpl_select_option,
@ -225,11 +227,15 @@
} }
}, },
isNewMessage: function (stanza) { isNewMessage: function (message) {
/* Given a stanza, determine whether it's a new /* Given a stanza, determine whether it's a new
* message, i.e. not a MAM archived one. * message, i.e. not a MAM archived one.
*/ */
return !(sizzle('result[xmlns="'+Strophe.NS.MAM+'"]', stanza).length); if (message instanceof Element) {
return !(sizzle('result[xmlns="'+Strophe.NS.MAM+'"]', message).length);
} else {
return !message.get('archive_id');
}
}, },
isOTRMessage: function (message) { isOTRMessage: function (message) {