@abraca/dabra 2.17.1 → 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.
@@ -16138,6 +16138,29 @@ var BackgroundSyncManager = class extends EventEmitter {
16138
16138
  for (const state of states) this.syncStates.set(state.docId, state);
16139
16139
  } catch {}
16140
16140
  }
16141
+ /**
16142
+ * Re-read persisted sync states from IndexedDB, merging in any docs not
16143
+ * already tracked in memory. Unlike `init()` this is **not** cached behind
16144
+ * `_initPromise` — every call hits IDB afresh.
16145
+ *
16146
+ * Why this exists: `init()` only ever loads IDB once. If a manager was
16147
+ * created while IDB was empty/mid-population (or a UI singleton was left
16148
+ * pointing at a manager whose in-memory map is stale after a connection
16149
+ * swap), the only thing that recovered the real counts was a full page
16150
+ * reload (which spins up a brand-new manager → fresh `_loadPersistedStates`).
16151
+ * Calling this re-hydrates from the same source a reload reads, so the
16152
+ * offline-sync panel can self-heal from a spurious "0/0" without a reload.
16153
+ *
16154
+ * Merge-only by design: an in-memory entry (possibly a fresher in-flight
16155
+ * `syncing`/`synced`) is never clobbered by the persisted copy; we only add
16156
+ * docs IDB knows about that memory doesn't.
16157
+ */
16158
+ async reloadPersistedStates() {
16159
+ try {
16160
+ const states = await this.persistence.getAllStates();
16161
+ for (const state of states) if (!this.syncStates.has(state.docId)) this.syncStates.set(state.docId, state);
16162
+ } catch {}
16163
+ }
16141
16164
  /** Sync all documents in the root tree. */
16142
16165
  async syncAll() {
16143
16166
  if (this._destroyed) return;