mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-31 21:38:18 +00:00
fix(syncguard): preserve bypass during duplicate resume
This commit is contained in:
1 parent
bc185d8bd0
commit
8381462950
2 files changed
+18
No files matched your search
@@ -66,6 +66,11 @@ export function useSyncGuardFeature(host: LiveSyncCore, createOverlay: SyncGuard
|
|||||||
guard.disable();
|
guard.disable();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// A duplicate resume in the same active catch-up must honour a user's
|
||||||
|
// explicit decision to continue editing rather than silently re-lock.
|
||||||
|
if (guard.wasBypassed && services.replicator.couchDbCatchUpActivityCount.value > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Duplicate resume notifications or a visibility transition must not discard an
|
// Duplicate resume notifications or a visibility transition must not discard an
|
||||||
// already active guard and expose a partly reflected Vault to the user.
|
// already active guard and expose a partly reflected Vault to the user.
|
||||||
if (guard.presentation.phase === "transferring" || guard.presentation.phase === "applying" ||
|
if (guard.presentation.phase === "transferring" || guard.presentation.phase === "applying" ||
|
||||||
|
|||||||
@@ -266,4 +266,17 @@ describe("useSyncGuardFeature", () => {
|
|||||||
expect(h.updates[h.updates.length - 1]?.phase).toBe("idle");
|
expect(h.updates[h.updates.length - 1]?.phase).toBe("idle");
|
||||||
await h.onUnload[0]();
|
await h.onUnload[0]();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("preserves manual bypass across duplicate resume while the same CouchDB pull remains active", async () => {
|
||||||
|
const h = setup({ minimumFiles: 2 });
|
||||||
|
await h.onResumed[0]();
|
||||||
|
h.couchDbCatchUpActivityCount.value = 1;
|
||||||
|
await h.parseHandlers[0]([receivedNote("first"), receivedNote("second")]);
|
||||||
|
expect(h.updates[h.updates.length - 1]?.phase).toBe("transferring");
|
||||||
|
h.bypass();
|
||||||
|
await h.onResumed[0]();
|
||||||
|
await h.parseHandlers[0]([receivedNote("third"), receivedNote("fourth")]);
|
||||||
|
expect(h.updates[h.updates.length - 1]?.phase).toBe("idle");
|
||||||
|
await h.onUnload[0]();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user