Repair on-boarding story if needed

This commit is contained in:
Fedor Indutny
2023-01-09 17:44:20 -08:00
committed by GitHub
parent e5638c0b20
commit be99c7dfdf

View File

@@ -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<void> {
const existingOnboardingStoryMessageIds = window.storage.get(
@@ -24,7 +25,11 @@ export async function findAndDeleteOnboardingStoryIfExists(): Promise<void> {
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;