useSidebarStatus.ts
1 import { useEffect, useState } from "react"; 2 import { api } from "@/lib/api"; 3 import type { StatusResponse } from "@/lib/api"; 4 5 const POLL_MS = 10_000; 6 7 /** 8 * Light-weight status poll for the app shell (sidebar). The Status page uses 9 * its own faster interval; we keep this slower to avoid duplicate load. 10 */ 11 export function useSidebarStatus() { 12 const [status, setStatus] = useState<StatusResponse | null>(null); 13 14 useEffect(() => { 15 const load = () => { 16 api 17 .getStatus() 18 .then(setStatus) 19 .catch(() => {}); 20 }; 21 load(); 22 const id = setInterval(load, POLL_MS); 23 return () => clearInterval(id); 24 }, []); 25 26 return status; 27 }