From 71041f323be98701c916bc81d082c9870270cdf1 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Wed, 29 Jan 2025 12:20:36 -0600 Subject: [PATCH] Fix accidental loop during backup import Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> --- ts/services/tapToViewMessagesDeletionService.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ts/services/tapToViewMessagesDeletionService.ts b/ts/services/tapToViewMessagesDeletionService.ts index 421b808e4c..bbec211cf4 100644 --- a/ts/services/tapToViewMessagesDeletionService.ts +++ b/ts/services/tapToViewMessagesDeletionService.ts @@ -89,6 +89,11 @@ class TapToViewMessagesDeletionService { } async #checkTapToViewMessages() { + if (!this.#shouldRun()) { + window.SignalContext.log.info('checkTapToViewMessages: not running'); + return; + } + const receivedAtMsForOldestTapToViewMessage = await DataReader.getNextTapToViewMessageTimestampToAgeOut(); if (!receivedAtMsForOldestTapToViewMessage) { @@ -116,12 +121,19 @@ class TapToViewMessagesDeletionService { clearTimeoutIfNecessary(this.#timeout); this.#timeout = setTimeout(async () => { - if (!this.#isPaused && !window.SignalContext.isTestOrMockEnvironment()) { - await eraseTapToViewMessages(); + if (!this.#shouldRun()) { + window.SignalContext.log.info('checkTapToViewMessages: not running'); + return; } + + await eraseTapToViewMessages(); this.update(); }, wait); } + + #shouldRun(): boolean { + return !this.#isPaused && !window.SignalContext.isTestOrMockEnvironment(); + } } export const tapToViewMessagesDeletionService =