Throttle unread updates

This commit is contained in:
trevor-signal
2025-05-05 14:36:11 -04:00
committed by GitHub
parent deec5fc1e2
commit 6d4fb10c27
6 changed files with 16 additions and 14 deletions
+9 -6
View File
@@ -287,6 +287,8 @@ export class ConversationModel extends window.Backbone
throttledUpdateVerified?: () => void;
throttledUpdateUnread: () => void;
typingRefreshTimer?: NodeJS.Timeout | null;
typingPauseTimer?: NodeJS.Timeout | null;
@@ -442,6 +444,7 @@ export class ConversationModel extends window.Backbone
this.isFetchingUUID = this.isSMSOnly();
this.throttledBumpTyping = throttle(this.bumpTyping, 300);
this.throttledUpdateUnread = throttle(this.#updateUnread, 300);
this.throttledUpdateSharedGroups = throttle(
this.updateSharedGroups.bind(this),
FIVE_MINUTES
@@ -3146,7 +3149,7 @@ export class ConversationModel extends window.Backbone
window.MessageCache.register(message);
drop(this.onNewMessage(message));
drop(this.updateUnread());
this.throttledUpdateUnread();
}
async addDeliveryIssue({
@@ -3190,7 +3193,7 @@ export class ConversationModel extends window.Backbone
window.MessageCache.register(message);
drop(this.onNewMessage(message));
drop(this.updateUnread());
this.throttledUpdateUnread();
await this.notify(message.attributes);
}
@@ -3373,7 +3376,7 @@ export class ConversationModel extends window.Backbone
window.MessageCache.register(message);
drop(this.onNewMessage(message));
drop(this.updateUnread());
this.throttledUpdateUnread();
const serviceId = this.getServiceId();
if (isDirectConversation(this.attributes) && serviceId) {
@@ -4801,7 +4804,7 @@ export class ConversationModel extends window.Backbone
window.MessageCache.register(message);
void this.addSingleMessage(message.attributes);
void this.updateUnread();
this.throttledUpdateUnread();
log.info(
`${logId}: added a notification received_at=${message.get('received_at')}`
@@ -4836,11 +4839,11 @@ export class ConversationModel extends window.Backbone
}
): Promise<void> {
await markConversationRead(this.attributes, newestUnreadAt, options);
await this.updateUnread();
this.throttledUpdateUnread();
window.reduxActions.callHistory.updateCallHistoryUnreadCount();
}
async updateUnread(): Promise<void> {
async #updateUnread(): Promise<void> {
const options = {
storyId: undefined,
includeStoryReplies: !isGroup(this.attributes),