okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
b6a38b328
main
1import { useEffect , useState } from 'react' ; 2import { api } from './client' ; 3 4/** 5* True while the host is still unpacking the engine that came inside the app (the first start; about a minute, longer on a busy disk). 6* The model list and the setup wait for it, so the page would otherwise sit on "Getting your setup ready…" with no reason given. 7*/ 8export function useEngineUnpacking ( active :boolean ) :boolean { 9const [ unpacking , setUnpacking ] = useState ( false ); 10useEffect (() => { 11if ( ! active ) return undefined ; 12let live = true ; 13const ask = () => api . get <{ engineSetup ?:boolean }>( '/api/control/status' ). then ( s => { if ( live ) setUnpacking ( s . engineSetup === true ); }, () => {}); 14void ask (); 15const timer = setInterval (() => void ask (), 2000 ); 16return () => { live = false ; clearInterval ( timer ); }; 17}, [ active ]); 18return unpacking ; 19}