Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: clear sync queue on finish

thecodrr854b45f8fc1a
diff --git a/packages/core/api/sync/index.js b/packages/core/api/sync/index.js
index 2aac25db2..0cc410f0d 100644
--- a/packages/core/api/sync/index.js
+++ b/packages/core/api/sync/index.js
@@ -230,7 +230,7 @@ class Sync {
arrays.types.push(type);
arrays.items.push(JSON.stringify(item));
- arrays.ids.push(itemId);
+ arrays.ids.push(id);
return arrays;
},
diff --git a/packages/core/api/sync/sync-queue.js b/packages/core/api/sync/sync-queue.js
index a0bb2db16..e812dcee3 100644
--- a/packages/core/api/sync/sync-queue.js
+++ b/packages/core/api/sync/sync-queue.js
@@ -33,10 +33,11 @@ export class SyncQueue {
const { itemIds } = syncQueue;
for (let id of ids) {
const index = itemIds.findIndex((i) => i === id);
- if (index <= -1) return;
+ if (index <= -1) continue;
syncQueue.itemIds.splice(index, 1);
}
- await this.save(syncQueue);
+ if (syncQueue.itemIds.length <= 0) await this.save(null);
+ else await this.save(syncQueue);
}
/**