add teacache

Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
Vladimir Mandic
2025-04-05 20:15:48 -04:00
parent fcde9f406d
commit 228da75a2e
15 changed files with 524 additions and 132 deletions
+13 -1
View File
@@ -1,4 +1,15 @@
let lastState = {};
let refreshInterval = 10000;
function setRefreshInterval() {
refreshInterval = opts.live_preview_refresh_period || 500;
log('refreshInterval', document.visibilityState, refreshInterval);
document.addEventListener('visibilitychange', () => {
if (document.hidden) refreshInterval = Math.max(2500, opts.live_preview_refresh_period || 1000);
else refreshInterval = opts.live_preview_refresh_period || 1000;
log('refreshInterval', document.visibilityState, refreshInterval);
});
}
function pad2(x) {
return x < 10 ? `0${x}` : x;
@@ -152,7 +163,8 @@ function requestProgress(id_task, progressEl, galleryEl, atEnd = null, onProgres
done();
};
xhrPost('./internal/progress', { id_task, id_live_preview }, onProgressHandler, onProgressErrorHandler, false, 30000);
const request_id = document.hidden ? -1 : id_live_preview;
xhrPost('./internal/progress', { id_task, request_id }, onProgressHandler, onProgressErrorHandler, false, 30000);
};
debug('livePreview start:', dateStart);
start(id_task, 0);
+1
View File
@@ -35,6 +35,7 @@ async function initStartup() {
window.subpath = window.opts.subpath;
window.api = `${window.subpath}/sdapi/v1`;
}
setRefreshInterval();
executeCallbacks(uiReadyCallbacks);
initLogMonitor();
setupExtraNetworks();