Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: always send sync request to client

Abdullah Atta5f0907168ff1
diff --git a/packages/core/src/api/index.js b/packages/core/src/api/index.js
index 0bd93be71..9d40dfec9 100644
--- a/packages/core/src/api/index.js
+++ b/packages/core/src/api/index.js
@@ -284,8 +284,8 @@ class Database {
return (await this.storage.read("lastSynced")) || 0;
}
- sync(full = true, force = false) {
- return this.syncer.start(full, force);
+ sync(full = true, force = false, lastSynced = null) {
+ return this.syncer.start(full, force, lastSynced);
}
/**
diff --git a/packages/core/src/api/sync/index.js b/packages/core/src/api/sync/index.js
index af2612644..0e799ea84 100644
--- a/packages/core/src/api/sync/index.js
+++ b/packages/core/src/api/sync/index.js
@@ -323,6 +323,11 @@ class Sync {
if (lastSynced > storedLastSynced)
await this.db.storage.write("lastSynced", lastSynced);
this.db.eventManager.publish(EVENTS.syncCompleted);
+
+ // refresh monographs on sync completed
+ await this.db.monographs.init();
+ // refresh topic references
+ this.db.notes.topicReferences.rebuild();
}
async cancel() {
@@ -359,13 +364,13 @@ class Sync {
/**
* @private
*/
- async onPushCompleted(lastSynced) {
- // refresh monographs on sync completed
- await this.db.monographs.init();
- // refresh topic references
- this.db.notes.topicReferences.rebuild();
-
- await this.start(false, false, lastSynced);
+ onPushCompleted(lastSynced) {
+ this.db.eventManager.publish(
+ EVENTS.databaseSyncRequested,
+ false,
+ false,
+ lastSynced
+ );
}
async processChunk(chunk, key, dbLastSynced, notify = false) {