"use client"; import { useState } from "react"; import { useLive } from "@/lib/live"; import { RefreshCw } from "lucide-react"; import { useT } from "@/components/I18n"; /** * PEP-114: a page opened before the site was updated may press buttons the new server doesn't * know — nothing happens and nothing is said. The live channel (`version`, PEP-225) brings the * server's boot id on every (re)connect: a restarted web means a new id, and the page asks to * reload. Never reloads by itself: the person may be in the middle of typing. */ export function VersionWatch({ boot }: { boot: string }) { const t = useT(); const [stale, setStale] = useState(false); useLive("version", (e) => { const now = e.type === "data" ? (e.data as { boot?: string }).boot : undefined; if (now && now !== boot) setStale(true); }); if (!stale) return null; return (
{t("FORGE обновилась. Обновите страницу — иначе кнопки на ней могут не сработать.")}
); }