mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +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 Conflicts from "./sync/conflicts";
|
||||||
import Session from "./session";
|
import Session from "./session";
|
||||||
import Constants from "../utils/constants";
|
import Constants from "../utils/constants";
|
||||||
import { EV, EVENTS } from "../common";
|
import { CHECK_IDS, EV, EVENTS, sendCheckUserStatusEvent } from "../common";
|
||||||
import Settings from "./settings";
|
import Settings from "./settings";
|
||||||
import Migrations from "./migrations";
|
import Migrations from "./migrations";
|
||||||
import Outbox from "./outbox";
|
import Outbox from "./outbox";
|
||||||
@@ -141,6 +141,7 @@ class Database {
|
|||||||
EV.publish(EVENTS.userEmailConfirmed);
|
EV.publish(EVENTS.userEmailConfirmed);
|
||||||
break;
|
break;
|
||||||
case "sync":
|
case "sync":
|
||||||
|
if (await sendCheckUserStatusEvent(CHECK_IDS.databaseSync))
|
||||||
await this.syncer.eventMerge(data);
|
await this.syncer.eventMerge(data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -151,8 +152,11 @@ class Database {
|
|||||||
return this.context.read("lastSynced");
|
return this.context.read("lastSynced");
|
||||||
}
|
}
|
||||||
|
|
||||||
_onDBWrite(item) {
|
async _onDBWrite(item) {
|
||||||
if (item.remote) {
|
if (
|
||||||
|
item.remote ||
|
||||||
|
!(await sendCheckUserStatusEvent(CHECK_IDS.databaseSync))
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearTimeout(this._syncTimeout);
|
clearTimeout(this._syncTimeout);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export const CHECK_IDS = {
|
|||||||
vaultAdd: "vault:add",
|
vaultAdd: "vault:add",
|
||||||
notebookAdd: "notebook:add",
|
notebookAdd: "notebook:add",
|
||||||
backupEncrypt: "backup:encrypt",
|
backupEncrypt: "backup:encrypt",
|
||||||
|
databaseSync: "database:sync",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EVENTS = {
|
export const EVENTS = {
|
||||||
|
|||||||
Reference in New Issue
Block a user