mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-01 19:49:54 +02:00
core: fix duplicate colors created during backup restore
This commit is contained in:
@@ -430,7 +430,6 @@ export default class Backup {
|
||||
}
|
||||
|
||||
private async migrateData(data: BackupDataItem[], version: number) {
|
||||
const queue: Partial<Record<CollectionName, MaybeDeletedItem<Item>[]>> = {};
|
||||
for (let item of data) {
|
||||
// we do not want to restore deleted items
|
||||
if (
|
||||
@@ -522,21 +521,16 @@ export default class Backup {
|
||||
const collectionKey: CollectionName = itemTypeToCollectionKey[itemType];
|
||||
if (!collectionKey) continue;
|
||||
|
||||
queue[collectionKey] = queue[collectionKey] || [];
|
||||
queue[collectionKey]?.push(item);
|
||||
}
|
||||
|
||||
for (const key in queue) {
|
||||
const collectionKey = key as CollectionName;
|
||||
const collection =
|
||||
collectionKey === "sessioncontent"
|
||||
? this.db.noteHistory.sessionContent.collection
|
||||
: this.db[collectionKey].collection;
|
||||
if (!collection) continue;
|
||||
const items = queue[collectionKey];
|
||||
if (!items) continue;
|
||||
|
||||
await collection.put(items as any[]);
|
||||
// items should sync immediately after getting restored
|
||||
item.dateModified = Date.now();
|
||||
item.synced = false;
|
||||
|
||||
await collection.upsert(item as any);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user