Skip to content

Commit ad8e4f6

Browse files
committed
chore: add disable slow timer button to dev options
1 parent ad3b7b3 commit ad8e4f6

File tree

3 files changed

+37
-23
lines changed

3 files changed

+37
-23
lines changed

frontend/src/html/popups.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<button class="xpBarTest">xp bar test</button>
6969
<button class="toggleFakeChartData">toggle fake chart data</button>
7070
<button class="toggleCaretDebug">toggle caret debug</button>
71+
<button class="disableSlowTimerFail">disable slow timer fail</button>
7172
</div>
7273
</dialog>
7374

frontend/src/ts/modals/dev-options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { update } from "../elements/xp-bar";
99
import { toggleUserFakeChartData } from "../test/result";
1010
import { toggleCaretDebug } from "../utils/caret";
1111
import { getInputElement } from "../input/input-element";
12+
import { disableSlowTimerFail } from "../test/test-timer";
1213

1314
let mediaQueryDebugLevel = 0;
1415

@@ -94,6 +95,11 @@ async function setup(modalEl: HTMLElement): Promise<void> {
9495
modalEl.querySelector(".toggleCaretDebug")?.addEventListener("click", () => {
9596
toggleCaretDebug();
9697
});
98+
modalEl
99+
.querySelector(".disableSlowTimerFail")
100+
?.addEventListener("click", () => {
101+
disableSlowTimerFail();
102+
});
97103
}
98104

99105
const modal = new AnimatedModal({

frontend/src/ts/test/test-timer.ts

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ let timer: NodeJS.Timeout | null = null;
3232
const interval = 1000;
3333
let expected = 0;
3434

35+
let slowTimerFailEnabled = true;
36+
export function disableSlowTimerFail(): void {
37+
slowTimerFailEnabled = false;
38+
}
39+
3540
let timerDebug = false;
3641
export function enableTimerDebug(): void {
3742
timerDebug = true;
@@ -234,30 +239,32 @@ export async function start(): Promise<void> {
234239
expected: expected,
235240
nextDelay: delay,
236241
});
237-
if (
238-
(Config.mode === "time" && Config.time < 130 && Config.time > 0) ||
239-
(Config.mode === "words" && Config.words < 250 && Config.words > 0)
240-
) {
241-
if (delay < interval / 2) {
242-
//slow timer
243-
SlowTimer.set();
244-
setLowFpsMode();
245-
}
246-
if (delay < interval / 10) {
247-
slowTimerCount++;
248-
if (slowTimerCount > 5) {
242+
if (slowTimerFailEnabled) {
243+
if (
244+
(Config.mode === "time" && Config.time < 130 && Config.time > 0) ||
245+
(Config.mode === "words" && Config.words < 250 && Config.words > 0)
246+
) {
247+
if (delay < interval / 2) {
249248
//slow timer
250-
251-
Notifications.add(
252-
'This could be caused by "efficiency mode" on Microsoft Edge.',
253-
);
254-
255-
Notifications.add(
256-
"Stopping the test due to bad performance. This would cause test calculations to be incorrect. If this happens a lot, please report this.",
257-
-1,
258-
);
259-
260-
TimerEvent.dispatch("fail", "slow timer");
249+
SlowTimer.set();
250+
setLowFpsMode();
251+
}
252+
if (delay < interval / 10) {
253+
slowTimerCount++;
254+
if (slowTimerCount > 5) {
255+
//slow timer
256+
257+
Notifications.add(
258+
'This could be caused by "efficiency mode" on Microsoft Edge.',
259+
);
260+
261+
Notifications.add(
262+
"Stopping the test due to bad performance. This would cause test calculations to be incorrect. If this happens a lot, please report this.",
263+
-1,
264+
);
265+
266+
TimerEvent.dispatch("fail", "slow timer");
267+
}
261268
}
262269
}
263270
}

0 commit comments

Comments
 (0)