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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 29 deletions

View file

@ -167,7 +167,6 @@ import { SeenStatus } from './MessageSeenStatus';
import MessageSender from './textsecure/SendMessage'; import MessageSender from './textsecure/SendMessage';
import type AccountManager from './textsecure/AccountManager'; import type AccountManager from './textsecure/AccountManager';
import { onStoryRecipientUpdate } from './util/onStoryRecipientUpdate'; import { onStoryRecipientUpdate } from './util/onStoryRecipientUpdate';
import { downloadOnboardingStory } from './util/downloadOnboardingStory';
import { flushAttachmentDownloadQueue } from './util/attachmentDownloadQueue'; import { flushAttachmentDownloadQueue } from './util/attachmentDownloadQueue';
import { StartupQueue } from './util/StartupQueue'; import { StartupQueue } from './util/StartupQueue';
import { showConfirmationDialog } from './util/showConfirmationDialog'; import { showConfirmationDialog } from './util/showConfirmationDialog';
@ -1146,7 +1145,6 @@ export async function startApp(): Promise<void> {
(async () => { (async () => {
menuOptions = await window.SignalContext.getMenuOptions(); menuOptions = await window.SignalContext.getMenuOptions();
})(), })(),
downloadOnboardingStory(),
]); ]);
await window.ConversationController.checkForConflicts(); await window.ConversationController.checkForConflicts();
} catch (error) { } catch (error) {
@ -1505,19 +1503,19 @@ export async function startApp(): Promise<void> {
log.info('Expiration start timestamp cleanup: complete'); log.info('Expiration start timestamp cleanup: complete');
log.info('listening for registration events'); log.info('listening for registration events');
window.Whisper.events.on('registration_done', () => { window.Whisper.events.on('registration_done', async () => {
log.info('handling registration event'); log.info('handling registration event');
strictAssert(server !== undefined, 'WebAPI not ready'); strictAssert(server !== undefined, 'WebAPI not ready');
void server.authenticate( await server.authenticate(
window.textsecure.storage.user.getWebAPICredentials() window.textsecure.storage.user.getWebAPICredentials()
); );
// Cancel throttled calls to refreshRemoteConfig since our auth changed. // Cancel throttled calls to refreshRemoteConfig since our auth changed.
window.Signal.RemoteConfig.maybeRefreshRemoteConfig.cancel(); window.Signal.RemoteConfig.maybeRefreshRemoteConfig.cancel();
void window.Signal.RemoteConfig.maybeRefreshRemoteConfig(server); drop(window.Signal.RemoteConfig.maybeRefreshRemoteConfig(server));
void connect(true); drop(connect(true));
}); });
cancelInitializationMessage(); cancelInitializationMessage();
@ -3013,6 +3011,9 @@ export async function startApp(): Promise<void> {
} }
await window.textsecure.storage.put(VERSION_KEY, window.getVersion()); await window.textsecure.storage.put(VERSION_KEY, window.getVersion());
// Re-hydrate items from memory; removeAllConfiguration above changed database
await window.storage.fetch();
log.info('unlinkAndDisconnect: Successfully cleared local configuration'); log.info('unlinkAndDisconnect: Successfully cleared local configuration');
} catch (eraseError) { } catch (eraseError) {
log.error( log.error(

View file

@ -59,6 +59,8 @@ import dataInterface from '../sql/Client';
import { MY_STORY_ID, StorySendMode } from '../types/Stories'; import { MY_STORY_ID, StorySendMode } from '../types/Stories';
import * as RemoteConfig from '../RemoteConfig'; import * as RemoteConfig from '../RemoteConfig';
import { findAndDeleteOnboardingStoryIfExists } from '../util/findAndDeleteOnboardingStoryIfExists'; import { findAndDeleteOnboardingStoryIfExists } from '../util/findAndDeleteOnboardingStoryIfExists';
import { downloadOnboardingStory } from '../util/downloadOnboardingStory';
import { drop } from '../util/drop';
const MY_STORY_BYTES = uuidToBytes(MY_STORY_ID); const MY_STORY_BYTES = uuidToBytes(MY_STORY_ID);
@ -1414,7 +1416,9 @@ export async function mergeAccountRecord(
hasViewedOnboardingStoryBool hasViewedOnboardingStoryBool
); );
if (hasViewedOnboardingStoryBool) { if (hasViewedOnboardingStoryBool) {
void findAndDeleteOnboardingStoryIfExists(); drop(findAndDeleteOnboardingStoryIfExists());
} else {
drop(downloadOnboardingStory());
} }
} }
{ {

View file

@ -17,6 +17,7 @@ export const STORAGE_UI_KEYS: ReadonlyArray<keyof StorageAccessType> = [
'call-system-notification', 'call-system-notification',
'customColors', 'customColors',
'defaultConversationColor', 'defaultConversationColor',
'existingOnboardingStoryMessageIds',
'hide-menu-bar', 'hide-menu-bar',
'incoming-call-notification', 'incoming-call-notification',
'notification-draw-attention', 'notification-draw-attention',

View file

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