mirror of
https://github.com/vladmandic/automatic
synced 2026-09-06 04:50:44 +02:00
Add fallback counter
This commit is contained in:
+22
-2
@@ -8,7 +8,6 @@ let outstanding = 0;
|
||||
let lastSort = 0;
|
||||
let lastSortName = 'None';
|
||||
let gallerySelection = { files: [], index: -1 };
|
||||
const galleryHashes = new Set();
|
||||
let maintenanceController = new AbortController();
|
||||
const folderStylesheet = new CSSStyleSheet();
|
||||
const fileStylesheet = new CSSStyleSheet();
|
||||
@@ -111,7 +110,8 @@ async function awaitForOutstanding(num, signal) {
|
||||
* @param {AbortSignal} signal - AbortController signal
|
||||
*/
|
||||
async function awaitForGallery(expectedSize, signal) {
|
||||
while (galleryHashes.size < expectedSize && !signal.aborted) await new Promise((resolve) => { setTimeout(resolve, 500); }); // longer interval because it's a low priority check
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
while (Math.max(galleryHashes.size, galleryHashes.fallback) < expectedSize && !signal.aborted) await new Promise((resolve) => { setTimeout(resolve, 500); }); // longer interval because it's a low priority check
|
||||
signal.throwIfAborted();
|
||||
}
|
||||
|
||||
@@ -185,6 +185,26 @@ function updateGalleryStyles() {
|
||||
|
||||
// Classes
|
||||
|
||||
class HashSet extends Set {
|
||||
constructor(val) {
|
||||
super(val);
|
||||
// Using a variable to store a counter has sometimes been unreliable in the past
|
||||
this.fallback = 0;
|
||||
}
|
||||
|
||||
add(value) {
|
||||
++this.fallback;
|
||||
super.add(value);
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.fallback = 0;
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
const galleryHashes = new HashSet();
|
||||
|
||||
class SimpleProgressBar {
|
||||
#container = document.createElement('div');
|
||||
#progress = document.createElement('div');
|
||||
|
||||
Reference in New Issue
Block a user