From be0e50f983fa7957c970f0fd6d6fe87382700cea Mon Sep 17 00:00:00 2001 From: WerWolv Date: Thu, 1 Feb 2024 12:40:37 +0100 Subject: [PATCH] web: Fix progress bar overflowing --- dist/web/source/wasm-config.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dist/web/source/wasm-config.js b/dist/web/source/wasm-config.js index a26337c0d..1393a8798 100644 --- a/dist/web/source/wasm-config.js +++ b/dist/web/source/wasm-config.js @@ -41,9 +41,12 @@ function monkeyPatch(progressFun) { } } monkeyPatch((file, done, total) => { - let percent = ((done / total) * 100).toFixed(0); - let mibNow = (done / 1024**2).toFixed(1); - let mibTotal = (total / 1024**2).toFixed(1); + if (total === 0 || done > total) + return; + + const percent = ((done / total) * 100).toFixed(0); + const mibNow = (done / 1024**2).toFixed(1); + const mibTotal = (total / 1024**2).toFixed(1); let root = document.querySelector(':root'); root.style.setProperty("--progress", `${percent}%`)