feat: auto-refresh the scan button until the worker finishes

This commit is contained in:
Jonathan
2026-07-11 17:40:27 +02:00
parent 612cd02b15
commit 2fb825140f
+10
View File
@@ -39,6 +39,16 @@ export function SettingsForm() {
setScanRequested(true); 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(() => { useEffect(() => {
fetch("/api/config") fetch("/api/config")
.then((r) => r.json()) .then((r) => r.json())