refactor: add `DEBUG:IMAGEHALT` localstorage variable that halts concurrent image loading
parent
6844cfe319
commit
9b5be08935
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue