Remove ts/services/timers.ts

This commit is contained in:
Fedor Indutny 2021-10-06 14:59:34 -07:00 committed by GitHub
parent 26eabf16a8
commit a537204fc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 38 additions and 144 deletions

View file

@ -54,7 +54,10 @@ export function start(): void {
this.on('add remove change:unreadCount', debouncedUpdateUnreadCount);
window.Whisper.events.on('updateUnreadCount', debouncedUpdateUnreadCount);
this.on('add', (model: ConversationModel): void => {
this.initMuteExpirationTimer(model);
// If the conversation is muted we set a timeout so when the mute expires
// we can reset the mute state on the model. If the mute has already expired
// then we reset the state right away.
model.startMuteTimer();
});
},
addActive(model: ConversationModel) {
@ -64,25 +67,6 @@ export function start(): void {
this.remove(model);
}
},
// If the conversation is muted we set a timeout so when the mute expires
// we can reset the mute state on the model. If the mute has already expired
// then we reset the state right away.
initMuteExpirationTimer(model: ConversationModel): void {
const muteExpiresAt = model.get('muteExpiresAt');
// This check for `muteExpiresAt` is likely redundant, but is needed to appease
// TypeScript.
if (model.isMuted() && muteExpiresAt) {
window.Signal.Services.onTimeout(
muteExpiresAt,
() => {
model.set({ muteExpiresAt: undefined });
},
model.getMuteTimeoutId()
);
} else if (muteExpiresAt) {
model.set({ muteExpiresAt: undefined });
}
},
updateUnreadCount() {
const canCountMutedConversations = window.storage.get(
'badge-count-muted-conversations'