Keep onboarding story message ids on unlink

This commit is contained in:
Scott Nonnenberg
2023-08-22 09:26:28 -07:00
committed by GitHub
parent 41d6dadb78
commit b7c17212c7
4 changed files with 17 additions and 29 deletions

View File

@@ -11,37 +11,19 @@ import { IMAGE_JPEG } from '../types/MIME';
import { ReadStatus } from '../messages/MessageReadStatus';
import { SeenStatus } from '../MessageSeenStatus';
import { findAndDeleteOnboardingStoryIfExists } from './findAndDeleteOnboardingStoryIfExists';
import { runStorageServiceSyncJob } from '../services/storage';
import { saveNewMessageBatcher } from './messageBatcher';
import { strictAssert } from './assert';
import { incrementMessageCounter } from './incrementMessageCounter';
// * Check if we've viewed onboarding story. Short circuit.
// * Run storage service sync (just in case) and check again.
// * If it has been viewed and it's downloaded on this device, delete & return.
// First, this function is meant to be run after a storage service sync
// * If onboarding story has been viewed and it's downloaded on this device,
// delete & return.
// * Check if we've already downloaded the onboarding story.
// * Download onboarding story, create db entry, mark as downloaded.
// * If story has been viewed mark as viewed on AccountRecord.
// * If we viewed it >24 hours ago, delete.
export async function downloadOnboardingStory(): Promise<void> {
const hasViewedOnboardingStory = window.storage.get(
'hasViewedOnboardingStory'
);
if (hasViewedOnboardingStory) {
await findAndDeleteOnboardingStoryIfExists();
return;
}
runStorageServiceSyncJob();
window.Whisper.events.once(
'storageService:syncComplete',
continueDownloadingOnboardingStory
);
}
async function continueDownloadingOnboardingStory(): Promise<void> {
const { server } = window.textsecure;
strictAssert(server, 'server not initialized');