|
@@ -151,7 +151,6 @@
|
|
|
},
|
|
|
|
|
|
afterMessagesFetched: function () {
|
|
|
- this.model.set('fetching_messages', false);
|
|
|
this.insertIntoDOM();
|
|
|
this.scrollDown();
|
|
|
// We only start listening for the scroll event after
|
|
@@ -160,7 +159,6 @@
|
|
|
},
|
|
|
|
|
|
fetchMessages: function () {
|
|
|
- this.model.set('fetching_messages', true);
|
|
|
this.model.messages.fetch({
|
|
|
'add': true,
|
|
|
'success': this.afterMessagesFetched.bind(this),
|
|
@@ -420,38 +418,12 @@
|
|
|
return !this.$el.is(':visible');
|
|
|
},
|
|
|
|
|
|
- updateNewMessageIndicators: function (message) {
|
|
|
- /* We have two indicators of new messages. The unread messages
|
|
|
- * counter, which shows the number of unread messages in
|
|
|
- * the document.title, and the "new messages" indicator in
|
|
|
- * a chat area, if it's scrolled up so that new messages
|
|
|
- * aren't visible.
|
|
|
- *
|
|
|
- * In both cases we ignore MAM messages.
|
|
|
- */
|
|
|
- if (!message.get('archive_id')) {
|
|
|
- if (this.model.get('scrolled', true)) {
|
|
|
- this.$el.find('.new-msgs-indicator').removeClass('hidden');
|
|
|
- }
|
|
|
- if (this.isNewMessageHidden()) {
|
|
|
- this.model.incrementUnreadMsgCounter();
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- isNewMessageHidden: function () {
|
|
|
- if (this.model.get('fetching_messages')) {
|
|
|
- // We seem to be busy fetching sessionStorage archived
|
|
|
- // messages, so the message is not considered new.
|
|
|
- return false;
|
|
|
- }
|
|
|
- return _converse.windowState === 'hidden' || this.model.isScrolledUp();
|
|
|
- },
|
|
|
-
|
|
|
handleTextMessage: function (message) {
|
|
|
this.showMessage(_.clone(message.attributes));
|
|
|
if (message.get('sender') !== 'me') {
|
|
|
- this.updateNewMessageIndicators(message);
|
|
|
+ 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
|
|
|
// gets scrolled down. We always want to scroll down
|
|
@@ -908,7 +880,7 @@
|
|
|
},
|
|
|
|
|
|
onWindowStateChanged: function (state) {
|
|
|
- if (this.model.get('num_unread', 0) && !this.isNewMessageHidden()) {
|
|
|
+ if (this.model.get('num_unread', 0) && !this.model.newMessageWillBeHidden()) {
|
|
|
this.model.clearUnreadMsgCounter();
|
|
|
}
|
|
|
}
|