feat: auto-refresh the scan button until the worker finishes
This commit is contained in:
@@ -39,6 +39,16 @@ export function SettingsForm() {
|
||||
setScanRequested(true);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!scanRequested) return;
|
||||
const id = setInterval(async () => {
|
||||
const s = await (await fetch("/api/scan")).json();
|
||||
setScanResult(s.result);
|
||||
if (!s.requested) setScanRequested(false); // worker finished the scan
|
||||
}, 2000);
|
||||
return () => clearInterval(id);
|
||||
}, [scanRequested]);
|
||||
|
||||
useEffect(() => {
|
||||
fetch("/api/config")
|
||||
.then((r) => r.json())
|
||||
|
||||
Reference in New Issue
Block a user