import { useEffect, useState } from 'react'; import { RefreshCwIcon } from 'lucide-react'; import { CONNECTION_EVENT, type ConnectionChange } from '../../lib/connection'; import { Button } from '../ui/button'; import { Callout } from '../ui/callout'; /** * Said above every page while a Recomaze service is not answering, so an * empty list or a zero reads as "not loaded" rather than "nothing there". * Goes away by itself once the service answers a later call. */ export const ConnectionNotice = (): JSX.Element | null => { const [down, setDown] = useState([]); useEffect(() => { const onChange = (event: Event): void => { const { host, up } = (event as CustomEvent).detail; setDown(current => { if (up) return current.filter(item => item !== host); return current.includes(host) ? current : [...current, host]; }); }; window.addEventListener(CONNECTION_EVENT, onChange); return () => window.removeEventListener(CONNECTION_EVENT, onChange); }, []); if (down.length === 0) return null; return (

Recomaze is not answering right now ({down.join(', ')}), so this page may show less than there is. Nothing is lost; try again in a moment.

); };