mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-24 02:18:15 +01:00
Fix duplicate all chats folder
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
} from '../../types/ChatFolder.js';
|
||||
import type { ReadableDB, WritableDB } from '../Interface.js';
|
||||
import { sql } from '../util.js';
|
||||
import { strictAssert } from '../../util/assert.js';
|
||||
|
||||
export type ChatFolderRow = Readonly<
|
||||
Omit<
|
||||
@@ -181,6 +182,37 @@ export function createAllChatsChatFolder(db: WritableDB): ChatFolder {
|
||||
})();
|
||||
}
|
||||
|
||||
export function upsertAllChatsChatFolderFromSync(
|
||||
db: WritableDB,
|
||||
chatFolder: ChatFolder
|
||||
): void {
|
||||
return db.transaction(() => {
|
||||
strictAssert(
|
||||
chatFolder.folderType === ChatFolderType.ALL,
|
||||
'Chat folder must have folderType=ALL'
|
||||
);
|
||||
|
||||
if (hasAllChatsChatFolder(db)) {
|
||||
const chatFolderRow = chatFolderToRow(chatFolder);
|
||||
const [query, params] = sql`
|
||||
UPDATE chatFolders
|
||||
SET
|
||||
id = ${chatFolderRow.id},
|
||||
position = ${chatFolderRow.position},
|
||||
storageID = ${chatFolderRow.storageID},
|
||||
storageVersion = ${chatFolderRow.storageVersion},
|
||||
storageUnknownFields = ${chatFolderRow.storageUnknownFields},
|
||||
storageNeedsSync = ${chatFolderRow.storageNeedsSync}
|
||||
WHERE
|
||||
folderType = ${ChatFolderType.ALL}
|
||||
`;
|
||||
db.prepare(query).run(params);
|
||||
} else {
|
||||
_insertChatFolder(db, chatFolder);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
export function updateChatFolder(db: WritableDB, chatFolder: ChatFolder): void {
|
||||
return db.transaction(() => {
|
||||
const chatFolderRow = chatFolderToRow(chatFolder);
|
||||
|
||||
Reference in New Issue
Block a user