From be99c7dfdf14c34e1c289c2b3cbf3f2fbfa45f8a Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Mon, 9 Jan 2023 17:44:20 -0800 Subject: [PATCH] Repair on-boarding story if needed --- ts/util/findAndDeleteOnboardingStoryIfExists.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ts/util/findAndDeleteOnboardingStoryIfExists.ts b/ts/util/findAndDeleteOnboardingStoryIfExists.ts index ed6cd24e2e..abcbb8d66e 100644 --- a/ts/util/findAndDeleteOnboardingStoryIfExists.ts +++ b/ts/util/findAndDeleteOnboardingStoryIfExists.ts @@ -4,6 +4,7 @@ import * as log from '../logging/log'; import { getMessageById } from '../messages/getMessageById'; import { calculateExpirationTimestamp } from './expirationTimer'; +import { DAY } from './durations'; export async function findAndDeleteOnboardingStoryIfExists(): Promise { const existingOnboardingStoryMessageIds = window.storage.get( @@ -24,7 +25,11 @@ export async function findAndDeleteOnboardingStoryIfExists(): Promise { const expires = calculateExpirationTimestamp(message.attributes) ?? 0; - return expires < Date.now(); + const now = Date.now(); + const isExpired = expires < now; + const needsRepair = expires > now + 2 * DAY; + + return isExpired || needsRepair; } return true;