import { WifiOff } from "lucide-react" import { AnimatePresence, motion } from "motion/react" import { useSyncExternalStore } from "react" import { ago } from "@/components/Health/queries" import { connectionStore } from "@/lib/connectionStore" import { fadeIn } from "@/lib/motion" import { isPortal } from "@/lib/portal" /** * Says when the installation cannot be reached, and when it was last heard * from. * * Only ever shown under a portal: a local install cannot lose contact with * itself. The screen underneath keeps its last data rather than blanking — * stale readings with a timestamp are more use than an empty page, which is * why the banner leads with when we last heard anything. */ export function ConnectionBanner() { const connection = useSyncExternalStore( connectionStore.subscribe, connectionStore.snapshot, connectionStore.snapshot, ) if (!isPortal()) return null return ( {connection.offline && (
Installation offline {connection.lastSeen ? `last seen ${ago(connection.lastSeen / 1000)} — reconnecting…` : "reconnecting…"}
)}
) }