diff --git a/packages/core/api/index.js b/packages/core/api/index.js index d63a64eff..3eca2fd2e 100644 --- a/packages/core/api/index.js +++ b/packages/core/api/index.js @@ -11,7 +11,7 @@ import Backup from "../database/backup"; import Conflicts from "./sync/conflicts"; import Session from "./session"; import Constants from "../utils/constants"; -import { EV, EVENTS } from "../common"; +import { CHECK_IDS, EV, EVENTS, sendCheckUserStatusEvent } from "../common"; import Settings from "./settings"; import Migrations from "./migrations"; import Outbox from "./outbox"; @@ -141,7 +141,8 @@ class Database { EV.publish(EVENTS.userEmailConfirmed); break; case "sync": - await this.syncer.eventMerge(data); + if (await sendCheckUserStatusEvent(CHECK_IDS.databaseSync)) + await this.syncer.eventMerge(data); break; } }; @@ -151,8 +152,11 @@ class Database { return this.context.read("lastSynced"); } - _onDBWrite(item) { - if (item.remote) { + async _onDBWrite(item) { + if ( + item.remote || + !(await sendCheckUserStatusEvent(CHECK_IDS.databaseSync)) + ) { return; } clearTimeout(this._syncTimeout); diff --git a/packages/core/common.js b/packages/core/common.js index 66945110d..f805f14c3 100644 --- a/packages/core/common.js +++ b/packages/core/common.js @@ -15,6 +15,7 @@ export const CHECK_IDS = { vaultAdd: "vault:add", notebookAdd: "notebook:add", backupEncrypt: "backup:encrypt", + databaseSync: "database:sync", }; export const EVENTS = {