From 95f01007a36dddb2d1261009c178571b8f189655 Mon Sep 17 00:00:00 2001 From: cmdr2 Date: Wed, 21 Sep 2022 15:14:22 +0530 Subject: [PATCH] Fix a bug where negative steps remaining would mess up the countdown --- ui/index.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/index.html b/ui/index.html index 2454da6e..fc849f7d 100644 --- a/ui/index.html +++ b/ui/index.html @@ -761,9 +761,11 @@ async function doMakeImage(reqBody, batchCount) { let overallStepCount = stepUpdate.step + batchesDone * batchSize let totalSteps = batchCount * batchSize let percent = 100 * (overallStepCount / totalSteps) + percent = (percent > 100 ? 100 : percent) percent = percent.toFixed(0) stepsRemaining = totalSteps - overallStepCount + stepsRemaining = (stepsRemaining < 0 ? 0 : stepsRemaining) timeRemaining = (timeTaken === -1 ? '' : stepsRemaining * timeTaken) // ms outputMsg.innerHTML = `Batch ${batchesDone+1} of ${batchCount}` @@ -1360,6 +1362,10 @@ function millisecondsToStr(milliseconds) { s += seconds + ' second' + numberEnding(seconds); } + if (s === '') { + s = 'almost done' + } + return s; }