Properly clear message counter upon page reload
This commit is contained in:
parent
744c575a6a
commit
e964e97285
25
converse.js
25
converse.js
@ -148,20 +148,29 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
xmppchat.updateMsgCounter = function () {
|
xmppchat.updateMsgCounter = function () {
|
||||||
this.msg_counter += 1;
|
|
||||||
if (this.msg_counter > 0) {
|
if (this.msg_counter > 0) {
|
||||||
if (document.title.search(/^Messages \(\d\) /) == -1) {
|
if (document.title.search(/^Messages \(\d+\) /) == -1) {
|
||||||
document.title = "Messages (" + this.msg_counter + ") " + document.title;
|
document.title = "Messages (" + this.msg_counter + ") " + document.title;
|
||||||
} else {
|
} else {
|
||||||
document.title = document.title.replace(/^Messages \(\d\) /, "Messages (" + this.msg_counter + ") ");
|
document.title = document.title.replace(/^Messages \(\d+\) /, "Messages (" + this.msg_counter + ") ");
|
||||||
}
|
}
|
||||||
window.blur();
|
window.blur();
|
||||||
window.focus();
|
window.focus();
|
||||||
} else if (document.title.search(/^\(\d\) /) !== -1) {
|
} else if (document.title.search(/^Messages \(\d+\) /) != -1) {
|
||||||
document.title = document.title.replace(/^Messages \(\d\) /, "");
|
document.title = document.title.replace(/^Messages \(\d+\) /, "");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xmppchat.incrementMsgCounter = function () {
|
||||||
|
this.msg_counter += 1;
|
||||||
|
this.updateMsgCounter();
|
||||||
|
};
|
||||||
|
|
||||||
|
xmppchat.clearMsgCounter = function () {
|
||||||
|
this.msg_counter = 0;
|
||||||
|
this.updateMsgCounter();
|
||||||
|
};
|
||||||
|
|
||||||
xmppchat.collections = {
|
xmppchat.collections = {
|
||||||
/* FIXME: XEP-0136 specifies 'urn:xmpp:archive' but the mod_archive_odbc
|
/* FIXME: XEP-0136 specifies 'urn:xmpp:archive' but the mod_archive_odbc
|
||||||
* add-on for ejabberd wants the URL below. This might break for other
|
* add-on for ejabberd wants the URL below. This might break for other
|
||||||
@ -333,7 +342,9 @@
|
|||||||
'extra_classes': message.get('delayed') && 'delayed' || ''
|
'extra_classes': message.get('delayed') && 'delayed' || ''
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
xmppchat.updateMsgCounter();
|
if (message.get('sender') != 'me') {
|
||||||
|
xmppchat.incrementMsgCounter();
|
||||||
|
}
|
||||||
this.scrollDown();
|
this.scrollDown();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -470,6 +481,7 @@
|
|||||||
|
|
||||||
this.$el.appendTo(xmppchat.chatboxesview.$el);
|
this.$el.appendTo(xmppchat.chatboxesview.$el);
|
||||||
this.render().show().model.messages.fetch({add: true});
|
this.render().show().model.messages.fetch({add: true});
|
||||||
|
xmppchat.clearMsgCounter();
|
||||||
},
|
},
|
||||||
|
|
||||||
template: _.template(
|
template: _.template(
|
||||||
@ -876,6 +888,7 @@
|
|||||||
this);
|
this);
|
||||||
this.$el.appendTo(xmppchat.chatboxesview.$el);
|
this.$el.appendTo(xmppchat.chatboxesview.$el);
|
||||||
this.render().show().model.messages.fetch({add: true});
|
this.render().show().model.messages.fetch({add: true});
|
||||||
|
xmppchat.clearMsgCounter();
|
||||||
},
|
},
|
||||||
|
|
||||||
onLeave: function () {
|
onLeave: function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user