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