When marking message read, ensure that peers have same read_at

When we mark a message as read, we go to the database to ensure that
older messages in this conversation are marked read as well. That
optimization was missing the read_at value provided to the starting
message, so now it is piped along to all of them.
This commit is contained in:
Scott Nonnenberg 2018-05-24 18:54:06 -07:00
parent 9400d1a538
commit 8c85f6e3a6
3 changed files with 15 additions and 10 deletions

View file

@ -45,7 +45,10 @@
return message
? message.markRead(receipt.get('read_at')).then(
function() {
this.notifyConversation(message);
// This notification may result in messages older than this one being
// marked read. We want those messages to have the same expire timer
// start time as this one, so we pass the read_at value through.
this.notifyConversation(message, receipt.get('read_at'));
this.remove(receipt);
}.bind(this)
)
@ -53,13 +56,13 @@
}.bind(this)
);
},
notifyConversation: function(message) {
notifyConversation: function(message, readAt) {
var conversation = ConversationController.get({
id: message.get('conversationId'),
});
if (conversation) {
conversation.onReadMessage(message);
conversation.onReadMessage(message, readAt);
}
},
}))();