fix(ui): align telemetry and laboratory navigation
This commit is contained in:
@@ -23,6 +23,7 @@ interface ComputeContourContextValue {
|
||||
selectedContour: ComputeContour | null;
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
telemetryRefreshGeneration: number;
|
||||
selectContour: (contourId: string) => void;
|
||||
createContour: (draft: ComputeContourDraft) => Promise<ComputeContour>;
|
||||
updateContour: (
|
||||
@@ -30,6 +31,7 @@ interface ComputeContourContextValue {
|
||||
draft: ComputeContourDraft,
|
||||
) => Promise<ComputeContour>;
|
||||
refresh: () => void;
|
||||
refreshTelemetry: () => void;
|
||||
}
|
||||
|
||||
const ComputeContourContext = createContext<ComputeContourContextValue | null>(null);
|
||||
@@ -42,7 +44,12 @@ export function ComputeContourProvider({ children }: { children: ReactNode }) {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [generation, setGeneration] = useState(0);
|
||||
const [telemetryRefreshGeneration, setTelemetryRefreshGeneration] = useState(0);
|
||||
const refresh = useCallback(() => setGeneration((value) => value + 1), []);
|
||||
const refreshTelemetry = useCallback(
|
||||
() => setTelemetryRefreshGeneration((value) => value + 1),
|
||||
[],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController();
|
||||
@@ -103,19 +110,23 @@ export function ComputeContourProvider({ children }: { children: ReactNode }) {
|
||||
selectedContour,
|
||||
loading,
|
||||
error,
|
||||
telemetryRefreshGeneration,
|
||||
selectContour,
|
||||
createContour,
|
||||
updateContour,
|
||||
refresh,
|
||||
refreshTelemetry,
|
||||
}), [
|
||||
contours,
|
||||
selectedContour,
|
||||
loading,
|
||||
error,
|
||||
telemetryRefreshGeneration,
|
||||
selectContour,
|
||||
createContour,
|
||||
updateContour,
|
||||
refresh,
|
||||
refreshTelemetry,
|
||||
]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -18,6 +18,7 @@ export interface WorkerTelemetryState {
|
||||
export function useWorkerTelemetry(
|
||||
pollMilliseconds = DEFAULT_WORKER_TELEMETRY_POLL_MILLISECONDS,
|
||||
enabled = true,
|
||||
externalRefreshGeneration = 0,
|
||||
): WorkerTelemetryState {
|
||||
const normalizedPollMilliseconds = normalizeWorkerTelemetryPollMilliseconds(
|
||||
pollMilliseconds,
|
||||
@@ -51,7 +52,7 @@ export function useWorkerTelemetry(
|
||||
if (!controller.signal.aborted) setLoading(false);
|
||||
});
|
||||
return () => controller.abort();
|
||||
}, [enabled, generation]);
|
||||
}, [enabled, externalRefreshGeneration, generation]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled || loading) return;
|
||||
|
||||
Reference in New Issue
Block a user