core: always send sync request to client

This commit is contained in:
Abdullah Atta
2023-09-05 18:01:44 +05:00
parent 48061962b1
commit 5f0907168f
2 changed files with 14 additions and 9 deletions

View File

@@ -284,8 +284,8 @@ class Database {
return (await this.storage.read("lastSynced")) || 0; return (await this.storage.read("lastSynced")) || 0;
} }
sync(full = true, force = false) { sync(full = true, force = false, lastSynced = null) {
return this.syncer.start(full, force); return this.syncer.start(full, force, lastSynced);
} }
/** /**

View File

@@ -323,6 +323,11 @@ class Sync {
if (lastSynced > storedLastSynced) if (lastSynced > storedLastSynced)
await this.db.storage.write("lastSynced", lastSynced); await this.db.storage.write("lastSynced", lastSynced);
this.db.eventManager.publish(EVENTS.syncCompleted); 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() { async cancel() {
@@ -359,13 +364,13 @@ class Sync {
/** /**
* @private * @private
*/ */
async onPushCompleted(lastSynced) { onPushCompleted(lastSynced) {
// refresh monographs on sync completed this.db.eventManager.publish(
await this.db.monographs.init(); EVENTS.databaseSyncRequested,
// refresh topic references false,
this.db.notes.topicReferences.rebuild(); false,
lastSynced
await this.start(false, false, lastSynced); );
} }
async processChunk(chunk, key, dbLastSynced, notify = false) { async processChunk(chunk, key, dbLastSynced, notify = false) {