mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-23 19:49:56 +01:00
web: add support for running pending sync
This commit is contained in:
committed by
Ammar Ahmed
parent
bff5e64484
commit
2db819de2b
@@ -40,7 +40,7 @@ import { NetworkCheck } from "../utils/network-check";
|
||||
|
||||
const networkCheck = new NetworkCheck();
|
||||
var syncStatusTimeout = 0;
|
||||
const BATCH_SIZE = 50;
|
||||
let pendingSync = false;
|
||||
|
||||
/**
|
||||
* @extends {BaseStore<AppStore>}
|
||||
@@ -288,8 +288,10 @@ class AppStore extends BaseStore {
|
||||
syncDisabled: !this.get().isSyncEnabled,
|
||||
offline: !navigator.onLine
|
||||
});
|
||||
if (this.isSyncing()) pendingSync = { full };
|
||||
return;
|
||||
}
|
||||
pendingSync = false;
|
||||
|
||||
clearTimeout(syncStatusTimeout);
|
||||
this.updateLastSynced();
|
||||
@@ -302,6 +304,12 @@ class AppStore extends BaseStore {
|
||||
this.updateSyncStatus("completed", true);
|
||||
|
||||
await this.updateLastSynced();
|
||||
|
||||
if (pendingSync) {
|
||||
logger.info("Running pending sync", pendingSync);
|
||||
pendingSync = false;
|
||||
await this.get().sync(pendingSync.full, false);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(err);
|
||||
if (err.cause === "MERGE_CONFLICT") {
|
||||
|
||||
Reference in New Issue
Block a user