Replace MessageController with MessageCache
This commit is contained in:
parent
ba1a8aad09
commit
7d35216fda
73 changed files with 2237 additions and 1229 deletions
|
@ -2,7 +2,6 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import * as log from '../logging/log';
|
||||
import { getMessageById } from '../messages/getMessageById';
|
||||
import { calculateExpirationTimestamp } from './expirationTimer';
|
||||
import { DAY } from './durations';
|
||||
|
||||
|
@ -16,23 +15,23 @@ export async function findAndDeleteOnboardingStoryIfExists(): Promise<void> {
|
|||
}
|
||||
|
||||
const hasExpired = await (async () => {
|
||||
for (const id of existingOnboardingStoryMessageIds) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const message = await getMessageById(id);
|
||||
if (!message) {
|
||||
continue;
|
||||
}
|
||||
const [storyId] = existingOnboardingStoryMessageIds;
|
||||
try {
|
||||
const messageAttributes = await window.MessageCache.resolveAttributes(
|
||||
'findAndDeleteOnboardingStoryIfExists',
|
||||
storyId
|
||||
);
|
||||
|
||||
const expires = calculateExpirationTimestamp(message.attributes) ?? 0;
|
||||
const expires = calculateExpirationTimestamp(messageAttributes) ?? 0;
|
||||
|
||||
const now = Date.now();
|
||||
const isExpired = expires < now;
|
||||
const needsRepair = expires > now + 2 * DAY;
|
||||
|
||||
return isExpired || needsRepair;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
})();
|
||||
|
||||
if (!hasExpired) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue