Timeline date headers

This commit is contained in:
Evan Hahn 2022-01-26 17:05:26 -06:00 committed by GitHub
parent 0fa069f260
commit f9440bf594
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 1183 additions and 771 deletions

View file

@ -213,6 +213,9 @@ export class ConversationModel extends window.Backbone
private isInReduxBatch = false;
// This number is recorded as an optimization and may be out of date.
private newestReceivedAtMarkedRead?: number;
override defaults(): Partial<ConversationAttributesType> {
return {
unreadCount: 0,
@ -4572,6 +4575,15 @@ export class ConversationModel extends window.Backbone
sendReadReceipts: true,
}
): Promise<void> {
// This early return is an optimization, not a guarantee.
const { newestReceivedAtMarkedRead } = this;
if (
typeof newestReceivedAtMarkedRead === 'number' &&
newestUnreadAt <= newestReceivedAtMarkedRead
) {
return;
}
await markConversationRead(this.attributes, newestUnreadAt, options);
const unreadCount = await window.Signal.Data.getTotalUnreadForConversation(
@ -4583,6 +4595,8 @@ export class ConversationModel extends window.Backbone
this.set({ unreadCount });
window.Signal.Data.updateConversation(this.attributes);
}
this.newestReceivedAtMarkedRead = newestUnreadAt;
}
// This is an expensive operation we use to populate the message request hero row. It