mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 05:12:14 +00:00
- Clear scoped reads before the server session changes - Reconcile every tab with a fresh access response
28 lines
732 B
TypeScript
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,
|
|
);
|
|
}
|