mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Throttle unread updates
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user