mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
Simplify and lint
This commit is contained in:
+11
-9
@@ -13,13 +13,12 @@ const fileStylesheet = new CSSStyleSheet();
|
||||
const iconStopwatch = String.fromCodePoint(9201);
|
||||
// Store separator states for the session
|
||||
const separatorStates = new Map();
|
||||
const galleryProgressBar = new SimpleProgressBar();
|
||||
const galleryProgressBar = new SimpleProgressBar(galleryHashes);
|
||||
const el = {
|
||||
folders: undefined,
|
||||
files: undefined,
|
||||
search: undefined,
|
||||
status: undefined,
|
||||
progress: undefined,
|
||||
btnSend: undefined,
|
||||
};
|
||||
|
||||
@@ -863,7 +862,7 @@ async function fetchFilesHT(evt, controller) {
|
||||
const t1 = performance.now();
|
||||
log(`gallery: folder=${evt.target.name} num=${numFiles} time=${Math.floor(t1 - t0)}ms`);
|
||||
updateStatusWithSort(['Folder', evt.target.name], ['Images', numFiles.toLocaleString()], `${iconStopwatch} ${Math.floor(t1 - t0).toLocaleString()}ms`);
|
||||
galleryProgressBar.setMax(numFiles);
|
||||
galleryProgressBar.start(numFiles);
|
||||
addSeparators();
|
||||
thumbCacheCleanup(evt.target.name, numFiles, controller);
|
||||
}
|
||||
@@ -874,7 +873,7 @@ async function fetchFilesWS(evt) { // fetch file-by-file list over websockets
|
||||
maintenanceController.abort('Gallery update'); // Abort previous controller
|
||||
maintenanceController = controller; // Point to new controller for next time
|
||||
galleryHashes.clear(); // Must happen AFTER the AbortController steps
|
||||
galleryProgressBar.clearProgress();
|
||||
galleryProgressBar.clear();
|
||||
|
||||
el.files.innerHTML = '';
|
||||
updateGalleryStyles();
|
||||
@@ -924,7 +923,7 @@ async function fetchFilesWS(evt) { // fetch file-by-file list over websockets
|
||||
// gallerySort();
|
||||
log(`gallery: folder=${evt.target.name} num=${numFiles} time=${Math.floor(t1 - t0)}ms`);
|
||||
updateStatusWithSort(['Folder', evt.target.name], ['Images', numFiles.toLocaleString()], `${iconStopwatch} ${Math.floor(t1 - t0).toLocaleString()}ms`);
|
||||
galleryProgressBar.setMax(numFiles);
|
||||
galleryProgressBar.start(numFiles);
|
||||
addSeparators();
|
||||
thumbCacheCleanup(evt.target.name, numFiles, controller);
|
||||
};
|
||||
@@ -990,16 +989,19 @@ async function initGallery() { // triggered on gradio change to monitor when ui
|
||||
el.files = gradioApp().getElementById('tab-gallery-files');
|
||||
el.status = gradioApp().getElementById('tab-gallery-status');
|
||||
el.search = gradioApp().querySelector('#tab-gallery-search textarea');
|
||||
el.progress = gradioApp().getElementById('tab-gallery-progress');
|
||||
if (!el.folders || !el.files || !el.status || !el.search || el.progress) {
|
||||
if (!el.folders || !el.files || !el.status || !el.search) {
|
||||
error('initGallery', 'Missing gallery elements');
|
||||
return;
|
||||
}
|
||||
updateGalleryStyles();
|
||||
injectGalleryStatusCSS();
|
||||
setOverlayAnimation();
|
||||
galleryProgressBar.attachTo(el.progress);
|
||||
galleryProgressBar.monitor(galleryHashes);
|
||||
const progress = gradioApp().getElementById('tab-gallery-progress');
|
||||
if (progress) {
|
||||
galleryProgressBar.attachTo(progress);
|
||||
} else {
|
||||
log('initGallery', 'Failed to attach loading progress bar');
|
||||
}
|
||||
el.search.addEventListener('input', gallerySearch);
|
||||
el.btnSend = gradioApp().getElementById('tab-gallery-send-image');
|
||||
document.getElementById('tab-gallery-files').style.height = opts.logmonitor_show ? '75vh' : '85vh';
|
||||
|
||||
Reference in New Issue
Block a user