Always repair unexpired stories

This commit is contained in:
Josh Perez 2022-05-11 17:02:26 -04:00 committed by GitHub
parent 0ba6a0926e
commit 253ab7517d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 17 deletions

View file

@ -38,11 +38,7 @@ import { normalizeUuid } from './util/normalizeUuid';
import { filter } from './util/iterables';
import { isNotNil } from './util/isNotNil';
import { IdleDetector } from './IdleDetector';
import {
getStoriesForRedux,
loadStories,
repairUnexpiredStories,
} from './services/storyLoader';
import { getStoriesForRedux, loadStories } from './services/storyLoader';
import { senderCertificateService } from './services/senderCertificate';
import { GROUP_CREDENTIALS_KEY } from './services/groupCredentialFetcher';
import * as KeyboardLayout from './services/keyboardLayout';
@ -720,13 +716,6 @@ export async function startApp(): Promise<void> {
window.storage.remove('remoteBuildExpiration');
}
if (
window.isBeforeVersion(lastVersion, 'v5.40.0') &&
window.isAfterVersion(lastVersion, 'v5.36.0')
) {
await repairUnexpiredStories();
}
if (window.isBeforeVersion(lastVersion, 'v1.29.2-beta.1')) {
// Stickers flags
await Promise.all([

View file

@ -14,6 +14,7 @@ let storyData: Array<MessageAttributesType> | undefined;
export async function loadStories(): Promise<void> {
storyData = await dataInterface.getOlderStories({});
await repairUnexpiredStories();
}
export function getStoryDataFromMessageAttributes(
@ -61,11 +62,7 @@ export function getStoriesForRedux(): Array<StoryDataType> {
return stories;
}
export async function repairUnexpiredStories(): Promise<void> {
if (!storyData) {
await loadStories();
}
async function repairUnexpiredStories(): Promise<void> {
strictAssert(storyData, 'Could not load stories');
const storiesWithExpiry = storyData
@ -78,6 +75,10 @@ export async function repairUnexpiredStories(): Promise<void> {
),
}));
if (!storiesWithExpiry.length) {
return;
}
log.info(
'repairUnexpiredStories: repairing number of stories',
storiesWithExpiry.length