From ad8e4f65b5bfe561ab6adf3abb269cd5048ca3c7 Mon Sep 17 00:00:00 2001 From: Miodec Date: Tue, 2 Dec 2025 15:54:48 +0100 Subject: [PATCH] chore: add disable slow timer button to dev options --- frontend/src/html/popups.html | 1 + frontend/src/ts/modals/dev-options.ts | 6 ++++ frontend/src/ts/test/test-timer.ts | 47 +++++++++++++++------------ 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/frontend/src/html/popups.html b/frontend/src/html/popups.html index bbe596c99..686dd1306 100644 --- a/frontend/src/html/popups.html +++ b/frontend/src/html/popups.html @@ -68,6 +68,7 @@ + diff --git a/frontend/src/ts/modals/dev-options.ts b/frontend/src/ts/modals/dev-options.ts index 36c632e53..9742c6e88 100644 --- a/frontend/src/ts/modals/dev-options.ts +++ b/frontend/src/ts/modals/dev-options.ts @@ -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 { modalEl.querySelector(".toggleCaretDebug")?.addEventListener("click", () => { toggleCaretDebug(); }); + modalEl + .querySelector(".disableSlowTimerFail") + ?.addEventListener("click", () => { + disableSlowTimerFail(); + }); } const modal = new AnimatedModal({ diff --git a/frontend/src/ts/test/test-timer.ts b/frontend/src/ts/test/test-timer.ts index 3418ebc3d..e0acebbd4 100644 --- a/frontend/src/ts/test/test-timer.ts +++ b/frontend/src/ts/test/test-timer.ts @@ -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 { 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"); + } } } }