refactor: add `DEBUG:IMAGEHALT` localstorage variable that halts concurrent image loading

feat/type-attributes
Tomáš Mládek 2023-08-24 08:27:10 +02:00
parent 6844cfe319
commit 9b5be08935
1 changed files with 8 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import { local } from "d3";
import debug from "debug";
const dbg = debug("upend:imageQueue");
@ -11,8 +12,11 @@ class ImageQueue {
}[] = [];
active = 0;
debugHalt: boolean;
constructor(concurrency: number) {
this.concurrency = concurrency;
this.debugHalt = Boolean(localStorage.getItem("DEBUG:IMAGEHALT"));
}
public add(
@ -44,6 +48,10 @@ class ImageQueue {
const next = this.queue.splice(nextIdx, 1)[0];
dbg(`Getting ${next.id}...`);
this.active += 1;
next.element.classList.add("image-loading");
if (this.debugHalt) {
return;
}
next
.callback()
.then(() => {
@ -57,7 +65,6 @@ class ImageQueue {
next.element.classList.remove("image-loading");
this.update();
});
next.element.classList.add("image-loading");
}
dbg(