Ensure that expired messages are removed from the frontend

This commit is contained in:
lilia 2016-09-21 16:26:42 -07:00
parent 02ea4f2475
commit 1383dc141f
4 changed files with 24 additions and 3 deletions

View file

@ -40,10 +40,14 @@
this.on('change:avatar', this.updateAvatarUrl);
this.on('destroy', this.revokeAvatarUrl);
this.on('read', this.countUnread);
this.on('read', this.onReadMessage);
},
countUnread: function() {
onReadMessage: function(message) {
if (this.messageCollection.get(message.id)) {
this.messageCollection.get(message.id).fetch();
}
return this.getUnread().then(function(unreadMessages) {
this.save({unreadCount: unreadMessages.length});
if (unreadMessages.length) {