Fix spinner appearing every 5 secds

This commit is contained in:
2026-03-08 18:23:20 -04:00
parent 54c56002ee
commit 4161ff9513
2 changed files with 15 additions and 7 deletions

View File

@@ -74,8 +74,12 @@
return timestamp < Date.now() / 1000;
}
async function fetchAll() {
let isFetching = false;
async function fetchAll(silent = false) {
if (isFetching) return;
isFetching = true;
try {
if (!silent) status = "loading";
const [sys, ota, upcoming] = await Promise.all([
getSystemInfo(),
getOTAStatus(),
@@ -91,6 +95,8 @@
status = "error";
errorMsg = e.message || "Connection failed";
}
} finally {
isFetching = false;
}
}
@@ -107,8 +113,8 @@
$effect(() => {
fetchAll();
// Poll for status updates every 5 seconds
const interval = setInterval(fetchAll, 5000);
// Poll for status updates every 5 seconds (silently to avoid flashing)
const interval = setInterval(() => fetchAll(true), 5000);
return () => clearInterval(interval);
});