okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-split-linuxui (83aa59fdc) into f-split-int2b6a38b328

main
867 B19 linesraw
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 {
9  const [unpacking, setUnpacking] = useState(false);
10  useEffect(() => {
11    if (!active) return undefined;
12    let live = true;
13    const ask = () => api.get<{ engineSetup?: boolean }>('/api/control/status').then(s => { if (live) setUnpacking(s.engineSetup === true); }, () => {});
14    void ask();
15    const timer = setInterval(() => void ask(), 2000);
16    return () => { live = false; clearInterval(timer); };
17  }, [active]);
18  return unpacking;
19}