24 lines
753 B
TypeScript
24 lines
753 B
TypeScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
|
|
import { syncBuildCommitFromHealth } from "@/lib/app-navigation";
|
|
|
|
/**
|
|
* Remember the running image's git commit when the tab becomes visible again.
|
|
*
|
|
* Navigation itself reads that snapshot: a stale tab does a document load on
|
|
* the next in-app jump, a current tab keeps the client router. No polling.
|
|
*/
|
|
export function StaleBuildGuard() {
|
|
useEffect(() => {
|
|
void syncBuildCommitFromHealth();
|
|
const onVisibility = () => {
|
|
if (document.visibilityState === "visible") void syncBuildCommitFromHealth();
|
|
};
|
|
document.addEventListener("visibilitychange", onVisibility);
|
|
return () => document.removeEventListener("visibilitychange", onVisibility);
|
|
}, []);
|
|
return null;
|
|
}
|