mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-19 00:03:36 +00:00
Keep web job status polling live while dashboard is open
This commit is contained in:
+15
-15
@@ -123,6 +123,8 @@
|
||||
const $ = id => document.getElementById(id);
|
||||
let statusTimer = null;
|
||||
let captionTimer = null;
|
||||
let lastIndexRunning = false;
|
||||
let lastCaptionRunning = false;
|
||||
let captionLastStatus = null;
|
||||
let thumbnailUrls = [];
|
||||
|
||||
@@ -222,13 +224,13 @@
|
||||
async function refreshStatus() {
|
||||
try {
|
||||
const s = await api('/api/jellyfin/index/status');
|
||||
const running = !!s.running;
|
||||
renderStatus(s);
|
||||
if (!s.running && statusTimer) {
|
||||
clearInterval(statusTimer);
|
||||
statusTimer = null;
|
||||
if (lastIndexRunning && !running) {
|
||||
loadLibraries();
|
||||
refreshHealth();
|
||||
}
|
||||
lastIndexRunning = running;
|
||||
return s;
|
||||
} catch (e) {
|
||||
$('indexStatus').className = 'status error';
|
||||
@@ -250,6 +252,7 @@
|
||||
body:JSON.stringify({library_ids:ids, force:$('forceIndex').checked})
|
||||
});
|
||||
renderStatus(s);
|
||||
lastIndexRunning = !!s.running;
|
||||
if (!statusTimer) statusTimer = setInterval(refreshStatus, 2000);
|
||||
} catch (e) {
|
||||
$('indexStatus').className = 'status error';
|
||||
@@ -324,14 +327,12 @@
|
||||
async function refreshCaptionStatus() {
|
||||
try {
|
||||
const s = await api('/api/caption/status');
|
||||
const running = !!s.running;
|
||||
renderCaptionStatus(s);
|
||||
if (s.running) {
|
||||
if (!captionTimer) captionTimer = setInterval(refreshCaptionStatus, 2000);
|
||||
} else if (captionTimer) {
|
||||
clearInterval(captionTimer);
|
||||
captionTimer = null;
|
||||
if (lastCaptionRunning && !running) {
|
||||
refreshHealth();
|
||||
}
|
||||
lastCaptionRunning = running;
|
||||
return s;
|
||||
} catch (e) {
|
||||
$('captionStatus').className = 'status error';
|
||||
@@ -353,7 +354,8 @@
|
||||
body:JSON.stringify({library_ids:ids, force:$('forceCaption').checked})
|
||||
});
|
||||
renderCaptionStatus(s);
|
||||
if (s.running && !captionTimer) captionTimer = setInterval(refreshCaptionStatus, 2000);
|
||||
lastCaptionRunning = !!s.running;
|
||||
if (!captionTimer) captionTimer = setInterval(refreshCaptionStatus, 2000);
|
||||
} catch (e) {
|
||||
$('captionStatus').className = 'status error';
|
||||
$('captionStatus').textContent = e.message;
|
||||
@@ -442,12 +444,10 @@
|
||||
|
||||
refreshHealth();
|
||||
loadLibraries();
|
||||
refreshStatus().then(s => {
|
||||
if (s && s.running && !statusTimer) statusTimer = setInterval(refreshStatus, 2000);
|
||||
});
|
||||
refreshCaptionStatus().then(s => {
|
||||
if (s && s.running && !captionTimer) captionTimer = setInterval(refreshCaptionStatus, 2000);
|
||||
});
|
||||
refreshStatus();
|
||||
refreshCaptionStatus();
|
||||
statusTimer = setInterval(refreshStatus, 2000);
|
||||
captionTimer = setInterval(refreshCaptionStatus, 2000);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user