No more type passed to removeAllConfiguration; keep more UI keys
This commit is contained in:
parent
046a3c4849
commit
d7177516c1
7 changed files with 31 additions and 51 deletions
|
@ -50,7 +50,6 @@ import type {
|
|||
UnprocessedUpdateType,
|
||||
CompatPreKeyType,
|
||||
} from './textsecure/Types.d';
|
||||
import type { RemoveAllConfiguration } from './types/RemoveAllConfiguration';
|
||||
import type { ServiceIdString, PniString, AciString } from './types/ServiceId';
|
||||
import { isServiceIdString, ServiceIdKind } from './types/ServiceId';
|
||||
import type { Address } from './types/Address';
|
||||
|
@ -2699,8 +2698,8 @@ export class SignalProtocolStore extends EventEmitter {
|
|||
this.emit('removeAllData');
|
||||
}
|
||||
|
||||
async removeAllConfiguration(mode: RemoveAllConfiguration): Promise<void> {
|
||||
await window.Signal.Data.removeAllConfiguration(mode);
|
||||
async removeAllConfiguration(): Promise<void> {
|
||||
await window.Signal.Data.removeAllConfiguration();
|
||||
await this.hydrateCaches();
|
||||
|
||||
window.storage.reset();
|
||||
|
|
|
@ -137,7 +137,6 @@ import {
|
|||
} from './util/handleRetry';
|
||||
import { themeChanged } from './shims/themeChanged';
|
||||
import { createIPCEvents } from './util/createIPCEvents';
|
||||
import { RemoveAllConfiguration } from './types/RemoveAllConfiguration';
|
||||
import type { ServiceIdString } from './types/ServiceId';
|
||||
import { ServiceIdKind, isServiceIdString } from './types/ServiceId';
|
||||
import { isAciString } from './util/isAciString';
|
||||
|
@ -849,7 +848,7 @@ export async function startApp(): Promise<void> {
|
|||
log.warn(
|
||||
`This instance has not been used for 30 days. Last heartbeat: ${lastHeartbeat}. Last startup: ${previousLastStartup}.`
|
||||
);
|
||||
await unlinkAndDisconnect(RemoveAllConfiguration.Soft);
|
||||
await unlinkAndDisconnect();
|
||||
}
|
||||
|
||||
// Start heartbeat timer
|
||||
|
@ -1343,7 +1342,7 @@ export async function startApp(): Promise<void> {
|
|||
});
|
||||
|
||||
window.Whisper.events.on('unlinkAndDisconnect', () => {
|
||||
void unlinkAndDisconnect(RemoveAllConfiguration.Full);
|
||||
void unlinkAndDisconnect();
|
||||
});
|
||||
|
||||
async function runStorageService() {
|
||||
|
@ -1784,7 +1783,7 @@ export async function startApp(): Promise<void> {
|
|||
|
||||
if (!window.textsecure.storage.user.getAci()) {
|
||||
log.error('UUID not captured during registration, unlinking');
|
||||
return unlinkAndDisconnect(RemoveAllConfiguration.Full);
|
||||
return unlinkAndDisconnect();
|
||||
}
|
||||
|
||||
if (connectCount === 1) {
|
||||
|
@ -1804,7 +1803,7 @@ export async function startApp(): Promise<void> {
|
|||
|
||||
if (!window.textsecure.storage.user.getPni()) {
|
||||
log.error('PNI not captured during registration, unlinking softly');
|
||||
return unlinkAndDisconnect(RemoveAllConfiguration.Soft);
|
||||
return unlinkAndDisconnect();
|
||||
}
|
||||
|
||||
if (firstRun === true && deviceId !== 1) {
|
||||
|
@ -2892,9 +2891,7 @@ export async function startApp(): Promise<void> {
|
|||
return false;
|
||||
}
|
||||
|
||||
async function unlinkAndDisconnect(
|
||||
mode: RemoveAllConfiguration
|
||||
): Promise<void> {
|
||||
async function unlinkAndDisconnect(): Promise<void> {
|
||||
window.Whisper.events.trigger('unauthorized');
|
||||
|
||||
log.warn(
|
||||
|
@ -2934,7 +2931,7 @@ export async function startApp(): Promise<void> {
|
|||
);
|
||||
|
||||
try {
|
||||
log.info(`unlinkAndDisconnect: removing configuration, mode ${mode}`);
|
||||
log.info('unlinkAndDisconnect: removing configuration');
|
||||
|
||||
// First, make changes to conversations in memory
|
||||
window.getConversations().forEach(conversation => {
|
||||
|
@ -2948,7 +2945,7 @@ export async function startApp(): Promise<void> {
|
|||
await window.Signal.Data.getItemById('manifestVersion');
|
||||
|
||||
// Finally, conversations in the database, and delete all config tables
|
||||
await window.textsecure.storage.protocol.removeAllConfiguration(mode);
|
||||
await window.textsecure.storage.protocol.removeAllConfiguration();
|
||||
|
||||
// These three bits of data are important to ensure that the app loads up
|
||||
// the conversation list, instead of showing just the QR code screen.
|
||||
|
@ -3001,7 +2998,7 @@ export async function startApp(): Promise<void> {
|
|||
error instanceof HTTPError &&
|
||||
(error.code === 401 || error.code === 403)
|
||||
) {
|
||||
void unlinkAndDisconnect(RemoveAllConfiguration.Full);
|
||||
void unlinkAndDisconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import type { QualifiedAddressStringType } from '../types/QualifiedAddress';
|
|||
import type { StoryDistributionIdString } from '../types/StoryDistributionId';
|
||||
import type { AciString, PniString, ServiceIdString } from '../types/ServiceId';
|
||||
import type { BadgeType } from '../badges/types';
|
||||
import type { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
||||
import type { LoggerType } from '../types/Logging';
|
||||
import type { ReadStatus } from '../messages/MessageReadStatus';
|
||||
import type { RawBodyRange } from '../types/BodyRange';
|
||||
|
@ -794,7 +793,7 @@ export type DataInterface = {
|
|||
countStoryReadsByConversation(conversationId: string): Promise<number>;
|
||||
|
||||
removeAll: () => Promise<void>;
|
||||
removeAllConfiguration: (type?: RemoveAllConfiguration) => Promise<void>;
|
||||
removeAllConfiguration: () => Promise<void>;
|
||||
eraseStorageServiceState: () => Promise<void>;
|
||||
|
||||
getMessagesNeedingUpgrade: (
|
||||
|
|
|
@ -44,12 +44,10 @@ import { consoleLogger } from '../util/consoleLogger';
|
|||
import { dropNull } from '../util/dropNull';
|
||||
import { isNormalNumber } from '../util/isNormalNumber';
|
||||
import { isNotNil } from '../util/isNotNil';
|
||||
import { missingCaseError } from '../util/missingCaseError';
|
||||
import { parseIntOrThrow } from '../util/parseIntOrThrow';
|
||||
import * as durations from '../util/durations';
|
||||
import { formatCountForLogging } from '../logging/formatCountForLogging';
|
||||
import type { ConversationColorType, CustomColorType } from '../types/Colors';
|
||||
import { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
||||
import type { BadgeType, BadgeImageType } from '../badges/types';
|
||||
import { parseBadgeCategory } from '../badges/BadgeCategory';
|
||||
import { parseBadgeImageTheme } from '../badges/BadgeImageTheme';
|
||||
|
@ -5682,9 +5680,7 @@ async function removeAll(): Promise<void> {
|
|||
}
|
||||
|
||||
// Anything that isn't user-visible data
|
||||
async function removeAllConfiguration(
|
||||
mode = RemoveAllConfiguration.Full
|
||||
): Promise<void> {
|
||||
async function removeAllConfiguration(): Promise<void> {
|
||||
const db = await getWritableInstance();
|
||||
|
||||
db.transaction(() => {
|
||||
|
@ -5704,26 +5700,16 @@ async function removeAllConfiguration(
|
|||
`
|
||||
);
|
||||
|
||||
if (mode === RemoveAllConfiguration.Full) {
|
||||
db.exec(
|
||||
`
|
||||
DELETE FROM items;
|
||||
`
|
||||
);
|
||||
} else if (mode === RemoveAllConfiguration.Soft) {
|
||||
const itemIds: ReadonlyArray<string> = db
|
||||
.prepare<EmptyQuery>('SELECT id FROM items')
|
||||
.pluck(true)
|
||||
.all();
|
||||
const itemIds: ReadonlyArray<string> = db
|
||||
.prepare<EmptyQuery>('SELECT id FROM items')
|
||||
.pluck(true)
|
||||
.all();
|
||||
|
||||
const allowedSet = new Set<string>(STORAGE_UI_KEYS);
|
||||
for (const id of itemIds) {
|
||||
if (!allowedSet.has(id)) {
|
||||
removeById(db, 'items', id);
|
||||
}
|
||||
const allowedSet = new Set<string>(STORAGE_UI_KEYS);
|
||||
for (const id of itemIds) {
|
||||
if (!allowedSet.has(id)) {
|
||||
removeById(db, 'items', id);
|
||||
}
|
||||
} else {
|
||||
throw missingCaseError(mode);
|
||||
}
|
||||
|
||||
db.exec(
|
||||
|
|
|
@ -24,7 +24,6 @@ import ProvisioningCipher from './ProvisioningCipher';
|
|||
import type { IncomingWebSocketRequest } from './WebsocketResources';
|
||||
import createTaskWithTimeout from './TaskWithTimeout';
|
||||
import * as Bytes from '../Bytes';
|
||||
import { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
||||
import * as Errors from '../types/errors';
|
||||
import { senderCertificateService } from '../services/senderCertificate';
|
||||
import {
|
||||
|
@ -1043,10 +1042,8 @@ export default class AccountManager extends EventTarget {
|
|||
);
|
||||
}
|
||||
} else {
|
||||
log.info('createAccount: Erasing configuration (soft)');
|
||||
await storage.protocol.removeAllConfiguration(
|
||||
RemoveAllConfiguration.Soft
|
||||
);
|
||||
log.info('createAccount: Erasing configuration');
|
||||
await storage.protocol.removeAllConfiguration();
|
||||
}
|
||||
|
||||
await senderCertificateService.clear();
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
// Copyright 2021 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export enum RemoveAllConfiguration {
|
||||
Full = 'Full',
|
||||
Soft = 'Soft',
|
||||
}
|
|
@ -11,6 +11,7 @@ export type ThemeSettingType = z.infer<typeof themeSettingSchema>;
|
|||
export const STORAGE_UI_KEYS: ReadonlyArray<keyof StorageAccessType> = [
|
||||
'always-relay-calls',
|
||||
'audio-notification',
|
||||
'audioMessage',
|
||||
'auto-download-update',
|
||||
'badge-count-muted-conversations',
|
||||
'call-ringtone-notification',
|
||||
|
@ -18,8 +19,13 @@ export const STORAGE_UI_KEYS: ReadonlyArray<keyof StorageAccessType> = [
|
|||
'customColors',
|
||||
'defaultConversationColor',
|
||||
'existingOnboardingStoryMessageIds',
|
||||
'formattingWarningShown',
|
||||
'hasCompletedSafetyNumberOnboarding',
|
||||
'hasCompletedUsernameLinkOnboarding',
|
||||
'hide-menu-bar',
|
||||
'incoming-call-notification',
|
||||
'localeOverride',
|
||||
'navTabsCollapsed',
|
||||
'notification-draw-attention',
|
||||
'notification-setting',
|
||||
'pinnedConversationIds',
|
||||
|
@ -29,11 +35,14 @@ export const STORAGE_UI_KEYS: ReadonlyArray<keyof StorageAccessType> = [
|
|||
'preferredLeftPaneWidth',
|
||||
'preferredReactionEmoji',
|
||||
'previousAudioDeviceModule',
|
||||
'sendEditWarningShown',
|
||||
'sent-media-quality',
|
||||
'showStickerPickerHint',
|
||||
'showStickersIntroduction',
|
||||
'skinTone',
|
||||
'spell-check',
|
||||
'system-tray-setting',
|
||||
'textFormatting',
|
||||
'theme-setting',
|
||||
'zoomFactor',
|
||||
];
|
||||
|
|
Loading…
Add table
Reference in a new issue