mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 06:29:29 +01:00
feat: add auto syncing to premium features
This commit is contained in:
@@ -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,6 +141,7 @@ class Database {
|
||||
EV.publish(EVENTS.userEmailConfirmed);
|
||||
break;
|
||||
case "sync":
|
||||
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);
|
||||
|
||||
@@ -15,6 +15,7 @@ export const CHECK_IDS = {
|
||||
vaultAdd: "vault:add",
|
||||
notebookAdd: "notebook:add",
|
||||
backupEncrypt: "backup:encrypt",
|
||||
databaseSync: "database:sync",
|
||||
};
|
||||
|
||||
export const EVENTS = {
|
||||
|
||||
Reference in New Issue
Block a user