Keep UI settings on heartbeat expiration
This commit is contained in:
parent
dcf29078f4
commit
798533a417
8 changed files with 84 additions and 12 deletions
|
@ -33,6 +33,7 @@ import { cleanDataForIpc } from './cleanDataForIpc';
|
|||
import { ReactionType } from '../types/Reactions';
|
||||
import { ConversationColorType, CustomColorType } from '../types/Colors';
|
||||
import type { ProcessGroupCallRingRequestResult } from '../types/Calling';
|
||||
import type { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
||||
|
||||
import {
|
||||
ConversationModelCollectionType,
|
||||
|
@ -1527,8 +1528,8 @@ async function removeAll() {
|
|||
await channels.removeAll();
|
||||
}
|
||||
|
||||
async function removeAllConfiguration() {
|
||||
await channels.removeAllConfiguration();
|
||||
async function removeAllConfiguration(type?: RemoveAllConfiguration) {
|
||||
await channels.removeAllConfiguration(type);
|
||||
}
|
||||
|
||||
async function cleanupOrphanedAttachments() {
|
||||
|
|
|
@ -19,6 +19,7 @@ import type { ProcessGroupCallRingRequestResult } from '../types/Calling';
|
|||
import { StorageAccessType } from '../types/Storage.d';
|
||||
import type { AttachmentType } from '../types/Attachment';
|
||||
import { BodyRangesType } from '../types/Util';
|
||||
import type { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
||||
|
||||
export type AttachmentDownloadJobTypeType =
|
||||
| 'long-message'
|
||||
|
@ -416,7 +417,7 @@ export type DataInterface = {
|
|||
getRecentEmojis: (limit?: number) => Promise<Array<EmojiType>>;
|
||||
|
||||
removeAll: () => Promise<void>;
|
||||
removeAllConfiguration: () => Promise<void>;
|
||||
removeAllConfiguration: (type?: RemoveAllConfiguration) => Promise<void>;
|
||||
|
||||
getMessagesNeedingUpgrade: (
|
||||
limit: number,
|
||||
|
|
|
@ -32,17 +32,20 @@ import {
|
|||
import { ReadStatus } from '../messages/MessageReadStatus';
|
||||
import { GroupV2MemberType } from '../model-types.d';
|
||||
import { ReactionType } from '../types/Reactions';
|
||||
import { STORAGE_UI_KEYS } from '../types/StorageUIKeys';
|
||||
import { StoredJob } from '../jobs/types';
|
||||
import { assert } from '../util/assert';
|
||||
import { combineNames } from '../util/combineNames';
|
||||
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 { ConversationColorType, CustomColorType } from '../types/Colors';
|
||||
import { ProcessGroupCallRingRequestResult } from '../types/Calling';
|
||||
import { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
||||
|
||||
import {
|
||||
AllItemsType,
|
||||
|
@ -5427,22 +5430,46 @@ async function removeAll(): Promise<void> {
|
|||
}
|
||||
|
||||
// Anything that isn't user-visible data
|
||||
async function removeAllConfiguration(): Promise<void> {
|
||||
async function removeAllConfiguration(
|
||||
mode = RemoveAllConfiguration.Full
|
||||
): Promise<void> {
|
||||
const db = getInstance();
|
||||
|
||||
db.transaction(() => {
|
||||
db.exec(
|
||||
`
|
||||
DELETE FROM identityKeys;
|
||||
DELETE FROM items;
|
||||
DELETE FROM preKeys;
|
||||
DELETE FROM senderKeys;
|
||||
DELETE FROM sessions;
|
||||
DELETE FROM signedPreKeys;
|
||||
DELETE FROM unprocessed;
|
||||
DELETE FROM jobs;
|
||||
`
|
||||
`
|
||||
);
|
||||
|
||||
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 allowedSet = new Set<string>(STORAGE_UI_KEYS);
|
||||
for (const id of itemIds) {
|
||||
if (!allowedSet.has(id)) {
|
||||
removeById('items', id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw missingCaseError(mode);
|
||||
}
|
||||
|
||||
db.exec(
|
||||
"UPDATE conversations SET json = json_remove(json, '$.senderKeyInfo');"
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue