From 5ed76b96452afa0186d7f4397b58e80f938b1afb Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 29 Jan 2025 09:53:00 -0800 Subject: [PATCH] Fix accidental loop during backup import --- 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 421b808e4..bbec211cf 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 =