mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
Merge branch 'fix/e2e-flakes' into release/v1.47.6
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
b4927e1ea4
8 files changed
+324
-24
No files matched your search
@@ -51,6 +51,8 @@ const READY: RecordSessionTransition = {
|
||||
|
||||
let transition = READY;
|
||||
let seeded = false;
|
||||
/** Bumped on every change this tab applies; see `recordSessionRevision`. */
|
||||
let revision = 0;
|
||||
const listeners = new Set<() => void>();
|
||||
let channel: BroadcastChannel | null = null;
|
||||
let storageListenerAttached = false;
|
||||
@@ -107,6 +109,7 @@ function applyWire(next: WireTransition): void {
|
||||
}
|
||||
transition = toSnapshot(next);
|
||||
seeded = true;
|
||||
revision += 1;
|
||||
notify();
|
||||
}
|
||||
|
||||
@@ -228,6 +231,26 @@ export function getRecordSessionTransition(): RecordSessionTransition {
|
||||
return transition;
|
||||
}
|
||||
|
||||
/**
|
||||
* A counter that moves whenever this tab applies a transition change — its own
|
||||
* publish, or one received from another tab.
|
||||
*
|
||||
* `fetchMe` reads it on both sides of its request. A `/api/auth/me` answered
|
||||
* across a change cannot say which side of that change the server read it on:
|
||||
* the switcher's own `queryClient.clear()` remounts the account query the
|
||||
* moment the hold goes up, so the initiator routinely has a `/me` in flight
|
||||
* beside its own `POST /api/account/switch`, and that answer can describe the
|
||||
* record the session has just left. Applied after the commit, it rewrites the
|
||||
* scope mirror back to the old record; every peer that has already settled
|
||||
* reads that write as a foreign switch and holds for a `/me` naming the old
|
||||
* record, which no server answer will ever give. The counter is how `fetchMe`
|
||||
* recognises such an answer and asks again instead of applying it.
|
||||
*/
|
||||
export function recordSessionRevision(): number {
|
||||
seed();
|
||||
return revision;
|
||||
}
|
||||
|
||||
export function subscribeToRecordSessionTransition(
|
||||
listener: () => void,
|
||||
): () => void {
|
||||
|
||||
Reference in new issue
Block a user