From 9b5be0893538e4169f2dda99422492213627f465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 24 Aug 2023 08:27:10 +0200 Subject: [PATCH] refactor: add `DEBUG:IMAGEHALT` localstorage variable that halts concurrent image loading --- webui/src/components/imageQueue.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/webui/src/components/imageQueue.ts b/webui/src/components/imageQueue.ts index ca4ea1c..5acd30c 100644 --- a/webui/src/components/imageQueue.ts +++ b/webui/src/components/imageQueue.ts @@ -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(