fix: clear sync queue on finish

This commit is contained in:
thecodrr
2022-03-30 16:36:21 +05:00
parent 4135028137
commit 854b45f8fc
2 changed files with 4 additions and 3 deletions

View File

@@ -230,7 +230,7 @@ class Sync {
arrays.types.push(type); arrays.types.push(type);
arrays.items.push(JSON.stringify(item)); arrays.items.push(JSON.stringify(item));
arrays.ids.push(itemId); arrays.ids.push(id);
return arrays; return arrays;
}, },

View File

@@ -33,10 +33,11 @@ export class SyncQueue {
const { itemIds } = syncQueue; const { itemIds } = syncQueue;
for (let id of ids) { for (let id of ids) {
const index = itemIds.findIndex((i) => i === id); const index = itemIds.findIndex((i) => i === id);
if (index <= -1) return; if (index <= -1) continue;
syncQueue.itemIds.splice(index, 1); syncQueue.itemIds.splice(index, 1);
} }
await this.save(syncQueue); if (syncQueue.itemIds.length <= 0) await this.save(null);
else await this.save(syncQueue);
} }
/** /**