Repair on-boarding story if needed
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
import { getMessageById } from '../messages/getMessageById';
|
import { getMessageById } from '../messages/getMessageById';
|
||||||
import { calculateExpirationTimestamp } from './expirationTimer';
|
import { calculateExpirationTimestamp } from './expirationTimer';
|
||||||
|
import { DAY } from './durations';
|
||||||
|
|
||||||
export async function findAndDeleteOnboardingStoryIfExists(): Promise<void> {
|
export async function findAndDeleteOnboardingStoryIfExists(): Promise<void> {
|
||||||
const existingOnboardingStoryMessageIds = window.storage.get(
|
const existingOnboardingStoryMessageIds = window.storage.get(
|
||||||
@@ -24,7 +25,11 @@ export async function findAndDeleteOnboardingStoryIfExists(): Promise<void> {
|
|||||||
|
|
||||||
const expires = calculateExpirationTimestamp(message.attributes) ?? 0;
|
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;
|
return true;
|
||||||
|
Reference in New Issue
Block a user