Files
HealthLog/src/hooks/use-record-session-transition.ts
T
Marc-André Bombeck 38214e4726 fix(02-12): hold peer tabs during record switches
- Clear scoped reads before the server session changes
- Reconcile every tab with a fresh access response
2026-08-06 15:06:12 +02:00

28 lines
732 B
TypeScript

"use client";
import { useSyncExternalStore } from "react";
import {
getRecordSessionTransition,
subscribeToRecordSessionTransition,
type RecordSessionTransition,
} from "@/lib/query-keys/record-session-transition";
const SERVER_TRANSITION: RecordSessionTransition = {
id: null,
phase: "ready",
expectedScope: undefined,
};
function getServerRecordSessionTransition(): RecordSessionTransition {
return SERVER_TRANSITION;
}
/** The tab-local view of a browser-wide record-session transition. */
export function useRecordSessionTransition(): RecordSessionTransition {
return useSyncExternalStore(
subscribeToRecordSessionTransition,
getRecordSessionTransition,
getServerRecordSessionTransition,
);
}