chore: add disable slow timer button to dev options

This commit is contained in:
Miodec 2025-12-02 15:54:48 +01:00
parent ad3b7b37d1
commit ad8e4f65b5
3 changed files with 34 additions and 20 deletions

View file

@ -68,6 +68,7 @@
<button class="xpBarTest">xp bar test</button>
<button class="toggleFakeChartData">toggle fake chart data</button>
<button class="toggleCaretDebug">toggle caret debug</button>
<button class="disableSlowTimerFail">disable slow timer fail</button>
</div>
</dialog>

View file

@ -9,6 +9,7 @@ import { update } from "../elements/xp-bar";
import { toggleUserFakeChartData } from "../test/result";
import { toggleCaretDebug } from "../utils/caret";
import { getInputElement } from "../input/input-element";
import { disableSlowTimerFail } from "../test/test-timer";
let mediaQueryDebugLevel = 0;
@ -94,6 +95,11 @@ async function setup(modalEl: HTMLElement): Promise<void> {
modalEl.querySelector(".toggleCaretDebug")?.addEventListener("click", () => {
toggleCaretDebug();
});
modalEl
.querySelector(".disableSlowTimerFail")
?.addEventListener("click", () => {
disableSlowTimerFail();
});
}
const modal = new AnimatedModal({

View file

@ -32,6 +32,11 @@ let timer: NodeJS.Timeout | null = null;
const interval = 1000;
let expected = 0;
let slowTimerFailEnabled = true;
export function disableSlowTimerFail(): void {
slowTimerFailEnabled = false;
}
let timerDebug = false;
export function enableTimerDebug(): void {
timerDebug = true;
@ -234,30 +239,32 @@ export async function start(): Promise<void> {
expected: expected,
nextDelay: delay,
});
if (
(Config.mode === "time" && Config.time < 130 && Config.time > 0) ||
(Config.mode === "words" && Config.words < 250 && Config.words > 0)
) {
if (delay < interval / 2) {
//slow timer
SlowTimer.set();
setLowFpsMode();
}
if (delay < interval / 10) {
slowTimerCount++;
if (slowTimerCount > 5) {
if (slowTimerFailEnabled) {
if (
(Config.mode === "time" && Config.time < 130 && Config.time > 0) ||
(Config.mode === "words" && Config.words < 250 && Config.words > 0)
) {
if (delay < interval / 2) {
//slow timer
SlowTimer.set();
setLowFpsMode();
}
if (delay < interval / 10) {
slowTimerCount++;
if (slowTimerCount > 5) {
//slow timer
Notifications.add(
'This could be caused by "efficiency mode" on Microsoft Edge.',
);
Notifications.add(
'This could be caused by "efficiency mode" on Microsoft Edge.',
);
Notifications.add(
"Stopping the test due to bad performance. This would cause test calculations to be incorrect. If this happens a lot, please report this.",
-1,
);
Notifications.add(
"Stopping the test due to bad performance. This would cause test calculations to be incorrect. If this happens a lot, please report this.",
-1,
);
TimerEvent.dispatch("fail", "slow timer");
TimerEvent.dispatch("fail", "slow timer");
}
}
}
}