fix: wpm sometimes goes negative in zen mode

kind of a band aid fix but its ok

closes #7099
This commit is contained in:
Miodec 2025-11-12 11:52:23 +01:00
parent 33880b3842
commit 8aa1f51c2c

View file

@ -138,11 +138,18 @@ export function setInvalid(): void {
}
export function calculateTestSeconds(now?: number): number {
if (now === undefined) {
return (end - start) / 1000;
} else {
return (now - start) / 1000;
let duration = (end - start) / 1000;
if (now !== undefined) {
duration = (now - start) / 1000;
}
if (Config.mode === "zen" && duration < 0) {
duration = 0;
console.log("Zen mode with negative duration detected, setting to 0");
}
return duration;
}
export function calculateWpmAndRaw(