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

@ -541,7 +541,7 @@
}
},
onReadMessage(message) {
onReadMessage(message, readAt) {
if (this.messageCollection.get(message.id)) {
this.messageCollection.get(message.id).fetch();
}
@ -558,7 +558,10 @@
// Lastly, we don't send read syncs for any message marked read due to a read
// sync. That's a notification explosion we don't need.
return this.queueJob(() =>
this.markRead(message.get('received_at'), { sendReadReceipts: false })
this.markRead(message.get('received_at'), {
sendReadReceipts: false,
readAt,
})
);
},
@ -1018,7 +1021,7 @@
'it was not in messageCollection.'
);
}
promises.push(m.markRead());
promises.push(m.markRead(options.readAt));
const errors = m.get('errors');
return {
sender: m.get('source'),