mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-18 07:51:27 +00:00
Keep plugin job status polling live while page is open
This commit is contained in:
@@ -109,6 +109,8 @@
|
||||
var currentConfig = null;
|
||||
var statusTimer = null;
|
||||
var captionTimer = null;
|
||||
var lastIndexRunning = false;
|
||||
var lastCaptionRunning = false;
|
||||
var lastCaptionStatus = null;
|
||||
|
||||
function selectedLibraryIds() {
|
||||
@@ -198,16 +200,13 @@
|
||||
function refreshStatus() {
|
||||
return ApiClient.getJSON(ApiClient.getUrl('Plugins/SceneSearch/IndexStatus'))
|
||||
.then(function (status) {
|
||||
var running = !!(status && status.running);
|
||||
renderStatus(status);
|
||||
if (status && status.running) {
|
||||
if (!statusTimer) {
|
||||
statusTimer = setInterval(refreshStatus, 2000);
|
||||
}
|
||||
} else if (statusTimer) {
|
||||
clearInterval(statusTimer);
|
||||
statusTimer = null;
|
||||
|
||||
if (lastIndexRunning && !running) {
|
||||
loadLibraries();
|
||||
}
|
||||
lastIndexRunning = running;
|
||||
})
|
||||
.catch(function () {
|
||||
renderStatus(null);
|
||||
@@ -314,15 +313,9 @@
|
||||
function refreshCaptionStatus() {
|
||||
return ApiClient.getJSON(ApiClient.getUrl('Plugins/SceneSearch/CaptionStatus'))
|
||||
.then(function (status) {
|
||||
var running = !!(status && status.running);
|
||||
renderCaptionStatus(status);
|
||||
if (status && status.running) {
|
||||
if (!captionTimer) {
|
||||
captionTimer = setInterval(refreshCaptionStatus, 2000);
|
||||
}
|
||||
} else if (captionTimer) {
|
||||
clearInterval(captionTimer);
|
||||
captionTimer = null;
|
||||
}
|
||||
lastCaptionRunning = running;
|
||||
})
|
||||
.catch(function () {
|
||||
renderCaptionStatus(null);
|
||||
@@ -351,6 +344,13 @@
|
||||
page.querySelector('#timeoutSeconds').value = config.TimeoutSeconds || 60;
|
||||
|
||||
return Promise.all([loadLibraries(), refreshStatus(), refreshCaptionStatus()]);
|
||||
}).then(function () {
|
||||
if (!statusTimer) {
|
||||
statusTimer = setInterval(refreshStatus, 2000);
|
||||
}
|
||||
if (!captionTimer) {
|
||||
captionTimer = setInterval(refreshCaptionStatus, 2000);
|
||||
}
|
||||
}).finally(function () {
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
@@ -400,6 +400,9 @@
|
||||
});
|
||||
}).then(function () {
|
||||
refreshStatus();
|
||||
if (!statusTimer) {
|
||||
statusTimer = setInterval(refreshStatus, 2000);
|
||||
}
|
||||
}).catch(function () {
|
||||
page.querySelector('#indexStatus').textContent =
|
||||
'Could not start indexing. Check Jellyfin logs and Scene Search API status.';
|
||||
@@ -431,6 +434,9 @@
|
||||
});
|
||||
}).then(function () {
|
||||
refreshCaptionStatus();
|
||||
if (!captionTimer) {
|
||||
captionTimer = setInterval(refreshCaptionStatus, 2000);
|
||||
}
|
||||
}).catch(function () {
|
||||
page.querySelector('#captionStatus').textContent =
|
||||
'Could not start captioning. Check Jellyfin logs and Scene Search API status.';
|
||||
|
||||
Reference in New Issue
Block a user