diff --git a/packages/core/src/api/sync/collector.ts b/packages/core/src/api/sync/collector.ts index 97ab5b533..28af685a5 100644 --- a/packages/core/src/api/sync/collector.ts +++ b/packages/core/src/api/sync/collector.ts @@ -53,7 +53,8 @@ class Collector { await collection.update( chunk.map((i) => i.id), - { synced: true } + { synced: true }, + { sendEvent: false } ); } } diff --git a/packages/core/src/database/sql-collection.ts b/packages/core/src/database/sql-collection.ts index 778aa99c7..490e30b89 100644 --- a/packages/core/src/database/sql-collection.ts +++ b/packages/core/src/database/sql-collection.ts @@ -166,7 +166,11 @@ export class SQLCollection< }); } - async update(ids: string[], partial: Partial>) { + async update( + ids: string[], + partial: Partial>, + options: { sendEvent: boolean } = { sendEvent: true } + ) { await this.db() .updateTable(this.type) .where("id", "in", ids) @@ -176,7 +180,9 @@ export class SQLCollection< synced: partial.synced || false }) .execute(); - this.eventManager.publish(EVENTS.databaseUpdated, ids); + if (options.sendEvent) { + this.eventManager.publish(EVENTS.databaseUpdated, ids); + } } async ids(sortOptions: GroupOptions): Promise {