avoiding triple reload in last job list

This commit is contained in:
2026-08-03 21:34:06 +00:00
parent 9b080bc860
commit bfc6128353
10 changed files with 77 additions and 11 deletions
+10
View File
@@ -69,10 +69,13 @@
}
let timer = null;
let requestInProgress = false;
async function refresh() {
if (requestInProgress) return;
const active = activeRows();
if (!active.length) return;
const ids = active.map(row => Number(row.dataset.jobId)).filter(Number.isInteger);
requestInProgress = true;
try {
const response = await fetch('/api/software-jobs/statuses', {
method: 'POST',
@@ -86,10 +89,17 @@
if (activeRows().length) timer = window.setTimeout(refresh, 3000);
} catch (_) {
timer = window.setTimeout(refresh, 5000);
} finally {
requestInProgress = false;
}
}
if (activeRows().length) timer = window.setTimeout(refresh, 1200);
window.addEventListener('asset-table-content-reloaded', event => {
if (event.detail?.table !== table || !activeRows().length) return;
if (timer) window.clearTimeout(timer);
timer = window.setTimeout(refresh, 250);
});
window.addEventListener('beforeunload', () => {
if (timer) window.clearTimeout(timer);
}, {once: true});