@abraca/dabra 2.17.2 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16085,6 +16085,29 @@ var BackgroundSyncManager = class extends EventEmitter {
|
|
|
16085
16085
|
for (const state of states) this.syncStates.set(state.docId, state);
|
|
16086
16086
|
} catch {}
|
|
16087
16087
|
}
|
|
16088
|
+
/**
|
|
16089
|
+
* Re-read persisted sync states from IndexedDB, merging in any docs not
|
|
16090
|
+
* already tracked in memory. Unlike `init()` this is **not** cached behind
|
|
16091
|
+
* `_initPromise` — every call hits IDB afresh.
|
|
16092
|
+
*
|
|
16093
|
+
* Why this exists: `init()` only ever loads IDB once. If a manager was
|
|
16094
|
+
* created while IDB was empty/mid-population (or a UI singleton was left
|
|
16095
|
+
* pointing at a manager whose in-memory map is stale after a connection
|
|
16096
|
+
* swap), the only thing that recovered the real counts was a full page
|
|
16097
|
+
* reload (which spins up a brand-new manager → fresh `_loadPersistedStates`).
|
|
16098
|
+
* Calling this re-hydrates from the same source a reload reads, so the
|
|
16099
|
+
* offline-sync panel can self-heal from a spurious "0/0" without a reload.
|
|
16100
|
+
*
|
|
16101
|
+
* Merge-only by design: an in-memory entry (possibly a fresher in-flight
|
|
16102
|
+
* `syncing`/`synced`) is never clobbered by the persisted copy; we only add
|
|
16103
|
+
* docs IDB knows about that memory doesn't.
|
|
16104
|
+
*/
|
|
16105
|
+
async reloadPersistedStates() {
|
|
16106
|
+
try {
|
|
16107
|
+
const states = await this.persistence.getAllStates();
|
|
16108
|
+
for (const state of states) if (!this.syncStates.has(state.docId)) this.syncStates.set(state.docId, state);
|
|
16109
|
+
} catch {}
|
|
16110
|
+
}
|
|
16088
16111
|
/** Sync all documents in the root tree. */
|
|
16089
16112
|
async syncAll() {
|
|
16090
16113
|
if (this._destroyed) return;
|