From 2fc2c7bbe07ec950fcf10fbdb1d453374fc6af68 Mon Sep 17 00:00:00 2001 From: Miodec Date: Sun, 21 Sep 2025 15:39:41 +0200 Subject: [PATCH 1/2] refactor: move testRestarting state to TestState --- .../ts/controllers/challenge-controller.ts | 3 +-- .../src/ts/controllers/input-controller.ts | 6 ++--- .../src/ts/controllers/route-controller.ts | 6 +++-- frontend/src/ts/test/test-logic.ts | 22 +++++++++---------- frontend/src/ts/test/test-state.ts | 17 ++++++++++++++ frontend/src/ts/test/test-ui.ts | 16 -------------- 6 files changed, 36 insertions(+), 34 deletions(-) diff --git a/frontend/src/ts/controllers/challenge-controller.ts b/frontend/src/ts/controllers/challenge-controller.ts index a807815bd422..30b6c5b6cc56 100644 --- a/frontend/src/ts/controllers/challenge-controller.ts +++ b/frontend/src/ts/controllers/challenge-controller.ts @@ -5,7 +5,6 @@ import * as ManualRestart from "../test/manual-restart-tracker"; import * as CustomText from "../test/custom-text"; import * as Funbox from "../test/funbox/funbox"; import Config, * as UpdateConfig from "../config"; -import * as TestUI from "../test/test-ui"; import * as ConfigEvent from "../observables/config-event"; import * as TestState from "../test/test-state"; import * as Loader from "../elements/loader"; @@ -28,7 +27,7 @@ export function clearActive(): void { if ( TestState.activeChallenge && !challengeLoading && - !TestUI.testRestarting + !TestState.testRestarting ) { Notifications.add("Challenge cleared", 0); TestState.setActiveChallenge(null); diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 670c571f0c93..7655f31bc6a1 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -1013,7 +1013,7 @@ $(document).on("keydown", async (event) => { if (!allowTyping) return; - if (!event.originalEvent?.isTrusted || TestUI.testRestarting) { + if (!event.originalEvent?.isTrusted || TestState.testRestarting) { event.preventDefault(); return; } @@ -1249,7 +1249,7 @@ $("#wordsInput").on("keyup", (event) => { }); $("#wordsInput").on("keyup", (event) => { - if (!event.originalEvent?.isTrusted || TestUI.testRestarting) { + if (!event.originalEvent?.isTrusted || TestState.testRestarting) { event.preventDefault(); return; } @@ -1269,7 +1269,7 @@ $("#wordsInput").on("beforeinput", (event) => { }); $("#wordsInput").on("input", async (event) => { - if (!event.originalEvent?.isTrusted || TestUI.testRestarting) { + if (!event.originalEvent?.isTrusted || TestState.testRestarting) { (event.target as HTMLInputElement).value = " "; return; } diff --git a/frontend/src/ts/controllers/route-controller.ts b/frontend/src/ts/controllers/route-controller.ts index 7843eb6baae9..739c4b92bdab 100644 --- a/frontend/src/ts/controllers/route-controller.ts +++ b/frontend/src/ts/controllers/route-controller.ts @@ -154,11 +154,13 @@ export async function navigate( ): Promise { if ( !options.force && - (TestUI.testRestarting || TestUI.resultCalculating || PageTransition.get()) + (TestState.testRestarting || + TestUI.resultCalculating || + PageTransition.get()) ) { console.debug( `navigate: ${url} ignored, page is busy (testRestarting: ${ - TestUI.testRestarting + TestState.testRestarting }, resultCalculating: ${ TestUI.resultCalculating }, pageTransition: ${PageTransition.get()})` diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index 083028946b9c..2e4b59ff3cf9 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -176,7 +176,7 @@ export function restart(options = {} as RestartOptions): void { return; } - if (TestUI.testRestarting || TestUI.resultCalculating) { + if (TestState.testRestarting || TestUI.resultCalculating) { options.event?.preventDefault(); return; } @@ -314,7 +314,7 @@ export function restart(options = {} as RestartOptions): void { el = $("#typingTest"); } TestUI.setResultVisible(false); - TestUI.setTestRestarting(true); + TestState.setTestRestarting(true); el.stop(true, true).animate( { opacity: 0, @@ -358,7 +358,7 @@ export function restart(options = {} as RestartOptions): void { const initResult = await init(); if (!initResult) { - TestUI.setTestRestarting(false); + TestState.setTestRestarting(false); return; } @@ -396,7 +396,7 @@ export function restart(options = {} as RestartOptions): void { LiveBurst.reset(); TestUI.updatePremid(); ManualRestart.reset(); - TestUI.setTestRestarting(false); + TestState.setTestRestarting(false); } ); } @@ -420,7 +420,7 @@ async function init(): Promise { ); } TestInitFailed.show(); - TestUI.setTestRestarting(false); + TestState.setTestRestarting(false); TestState.setTestInitSuccess(false); Focus.set(false); // Notifications.add( @@ -1442,7 +1442,7 @@ $(".pageTest").on("click", "#restartTestButtonWithSameWordset", () => { }); $(".pageTest").on("click", "#testConfig .mode .textButton", (e) => { - if (TestUI.testRestarting) return; + if (TestState.testRestarting) return; if ($(e.currentTarget).hasClass("active")) return; const mode = ($(e.currentTarget).attr("mode") ?? "time") as Mode; if (mode === undefined) return; @@ -1453,7 +1453,7 @@ $(".pageTest").on("click", "#testConfig .mode .textButton", (e) => { }); $(".pageTest").on("click", "#testConfig .wordCount .textButton", (e) => { - if (TestUI.testRestarting) return; + if (TestState.testRestarting) return; const wrd = $(e.currentTarget).attr("wordCount") ?? "15"; if (wrd !== "custom") { if (UpdateConfig.setWordCount(parseInt(wrd))) { @@ -1464,7 +1464,7 @@ $(".pageTest").on("click", "#testConfig .wordCount .textButton", (e) => { }); $(".pageTest").on("click", "#testConfig .time .textButton", (e) => { - if (TestUI.testRestarting) return; + if (TestState.testRestarting) return; const mode = $(e.currentTarget).attr("timeConfig") ?? "10"; if (mode !== "custom") { if (UpdateConfig.setTimeConfig(parseInt(mode))) { @@ -1475,7 +1475,7 @@ $(".pageTest").on("click", "#testConfig .time .textButton", (e) => { }); $(".pageTest").on("click", "#testConfig .quoteLength .textButton", (e) => { - if (TestUI.testRestarting) return; + if (TestState.testRestarting) return; const lenAttr = $(e.currentTarget).attr("quoteLength"); if (lenAttr === "all") { if (UpdateConfig.setQuoteLengthAll()) { @@ -1503,7 +1503,7 @@ $(".pageTest").on("click", "#testConfig .quoteLength .textButton", (e) => { }); $(".pageTest").on("click", "#testConfig .punctuationMode.textButton", () => { - if (TestUI.testRestarting) return; + if (TestState.testRestarting) return; if (UpdateConfig.setPunctuation(!Config.punctuation)) { ManualRestart.set(); restart(); @@ -1511,7 +1511,7 @@ $(".pageTest").on("click", "#testConfig .punctuationMode.textButton", () => { }); $(".pageTest").on("click", "#testConfig .numbersMode.textButton", () => { - if (TestUI.testRestarting) return; + if (TestState.testRestarting) return; if (UpdateConfig.setNumbers(!Config.numbers)) { ManualRestart.set(); restart(); diff --git a/frontend/src/ts/test/test-state.ts b/frontend/src/ts/test/test-state.ts index 97a066578e39..fff613d180ab 100644 --- a/frontend/src/ts/test/test-state.ts +++ b/frontend/src/ts/test/test-state.ts @@ -1,4 +1,5 @@ import { Challenge } from "@monkeytype/schemas/challenges"; +import { promiseWithResolvers } from "../utils/misc"; export let isRepeated = false; export let isPaceRepeat = false; @@ -12,6 +13,7 @@ export let testInitSuccess = true; export let lineScrollDistance = 0; export let isLanguageRightToLeft = false; export let isDirectionReversed = false; +export let testRestarting = false; export function setRepeated(tf: boolean): void { isRepeated = tf; @@ -68,3 +70,18 @@ export function setIsLanguageRightToLeft(rtl: boolean): void { export function setIsDirectionReversed(val: boolean): void { isDirectionReversed = val; } + +let { promise: testRestartingPromise, resolve: restartingResolve } = + promiseWithResolvers(); + +export { testRestartingPromise }; + +export function setTestRestarting(val: boolean): void { + testRestarting = val; + if (val) { + ({ promise: testRestartingPromise, resolve: restartingResolve } = + promiseWithResolvers()); + } else { + restartingResolve(); + } +} diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index 61c19781969a..bdbafef40ca8 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -118,7 +118,6 @@ ConfigEvent.subscribe((eventKey, eventValue, nosave) => { export let resultVisible = false; export let activeWordTop = 0; -export let testRestarting = false; export let lineTransition = false; export let currentTestLine = 0; export let resultCalculating = false; @@ -131,21 +130,6 @@ export function setActiveWordTop(val: number): void { activeWordTop = val; } -let { promise: testRestartingPromise, resolve: restartingResolve } = - Misc.promiseWithResolvers(); - -export { testRestartingPromise }; - -export function setTestRestarting(val: boolean): void { - testRestarting = val; - if (val) { - ({ promise: testRestartingPromise, resolve: restartingResolve } = - Misc.promiseWithResolvers()); - } else { - restartingResolve(); - } -} - export function setResultCalculating(val: boolean): void { resultCalculating = val; } From 1479a269272c82f521b1b52981b87b1bf8b0e2b4 Mon Sep 17 00:00:00 2001 From: Miodec Date: Sun, 21 Sep 2025 15:42:26 +0200 Subject: [PATCH 2/2] refactor: move resultVisible state to TestState --- .../src/ts/commandline/lists/result-screen.ts | 15 ++++++++------- .../src/ts/controllers/input-controller.ts | 16 ++++++++-------- .../src/ts/controllers/pw-ad-controller.ts | 4 ++-- frontend/src/ts/test/pace-caret.ts | 3 +-- frontend/src/ts/test/result.ts | 7 ++++--- frontend/src/ts/test/test-logic.ts | 10 +++++----- frontend/src/ts/test/test-screenshot.ts | 6 +++--- frontend/src/ts/test/test-state.ts | 5 +++++ frontend/src/ts/test/test-ui.ts | 19 +++++++------------ frontend/src/ts/ui.ts | 2 +- 10 files changed, 44 insertions(+), 43 deletions(-) diff --git a/frontend/src/ts/commandline/lists/result-screen.ts b/frontend/src/ts/commandline/lists/result-screen.ts index a733aeb94b3f..7688b2d0a465 100644 --- a/frontend/src/ts/commandline/lists/result-screen.ts +++ b/frontend/src/ts/commandline/lists/result-screen.ts @@ -3,6 +3,7 @@ import * as TestUI from "../../test/test-ui"; import * as PractiseWordsModal from "../../modals/practise-words"; import * as Notifications from "../../elements/notifications"; import * as TestInput from "../../test/test-input"; +import * as TestState from "../../test/test-state"; import * as TestWords from "../../test/test-words"; import Config from "../../config"; import * as PractiseWords from "../../test/practise-words"; @@ -53,7 +54,7 @@ const commands: Command[] = [ alias: "restart start begin type test typing", icon: "fa-chevron-right", available: (): boolean => { - return TestUI.resultVisible; + return TestState.resultVisible; }, exec: (): void => { TestLogic.restart(); @@ -69,7 +70,7 @@ const commands: Command[] = [ }); }, available: (): boolean => { - return TestUI.resultVisible; + return TestState.resultVisible; }, }, { @@ -78,7 +79,7 @@ const commands: Command[] = [ icon: "fa-exclamation-triangle", subgroup: practiceSubgroup, available: (): boolean => { - return TestUI.resultVisible; + return TestState.resultVisible; }, }, { @@ -89,7 +90,7 @@ const commands: Command[] = [ TestUI.toggleResultWords(); }, available: (): boolean => { - return TestUI.resultVisible; + return TestState.resultVisible; }, }, { @@ -103,7 +104,7 @@ const commands: Command[] = [ }, 500); }, available: (): boolean => { - return TestUI.resultVisible; + return TestState.resultVisible; }, }, { @@ -117,7 +118,7 @@ const commands: Command[] = [ }, 500); }, available: (): boolean => { - return TestUI.resultVisible; + return TestState.resultVisible; }, }, { @@ -141,7 +142,7 @@ const commands: Command[] = [ ); }, available: (): boolean => { - return TestUI.resultVisible; + return TestState.resultVisible; }, }, ]; diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 7655f31bc6a1..fb5aed906663 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -447,7 +447,7 @@ async function handleChar( charIndex: number, realInputValue?: string ): Promise { - if (TestUI.resultCalculating || TestUI.resultVisible) { + if (TestUI.resultCalculating || TestState.resultVisible) { return; } @@ -802,7 +802,7 @@ async function handleTab( event.preventDefault(); // insert tab character if needed (only during the test) - if (!TestUI.resultVisible && shouldInsertTabCharacter) { + if (!TestState.resultVisible && shouldInsertTabCharacter) { await handleChar("\t", TestInput.input.current.length); setWordsInput(" " + TestInput.input.current); return; @@ -828,7 +828,7 @@ async function handleTab( } // insert tab character if needed (only during the test) - if (!TestUI.resultVisible && shouldInsertTabCharacter) { + if (!TestState.resultVisible && shouldInsertTabCharacter) { event.preventDefault(); await handleChar("\t", TestInput.input.current.length); setWordsInput(" " + TestInput.input.current); @@ -844,7 +844,7 @@ async function handleTab( //only special handlig on the test page if (ActivePage.get() !== "test") return; - if (TestUI.resultVisible) return; + if (TestState.resultVisible) return; // insert tab character if needed if (shouldInsertTabCharacter) { @@ -870,7 +870,7 @@ $("#wordsInput").on("keydown", (event) => { pageTestActive && !commandLineVisible && !popupVisible && - !TestUI.resultVisible && + !TestState.resultVisible && event.key !== "Enter" && !awaitingNextWord && TestState.testInitSuccess; @@ -911,7 +911,7 @@ $(document).on("keydown", async (event) => { pageTestActive && !commandLineVisible && !popupVisible && - !TestUI.resultVisible && + !TestState.resultVisible && (wordsFocused || event.key !== "Enter") && !awaitingNextWord; @@ -983,7 +983,7 @@ $(document).on("keydown", async (event) => { return; } - if (TestUI.resultVisible) { + if (TestState.resultVisible) { TestLogic.restart({ event, }); @@ -1258,7 +1258,7 @@ $("#wordsInput").on("keyup", (event) => { if (IgnoredKeys.includes(event.key)) return; - if (TestUI.resultVisible) return; + if (TestState.resultVisible) return; }); $("#wordsInput").on("beforeinput", (event) => { diff --git a/frontend/src/ts/controllers/pw-ad-controller.ts b/frontend/src/ts/controllers/pw-ad-controller.ts index e6ab88f63786..159112e6ac34 100644 --- a/frontend/src/ts/controllers/pw-ad-controller.ts +++ b/frontend/src/ts/controllers/pw-ad-controller.ts @@ -5,7 +5,7 @@ import Config from "../config"; import * as ActivePage from "../states/active-page"; -import * as TestUI from "../test/test-ui"; +import * as TestState from "../test/test-state"; // Step 1: Create the Ramp Object, NOTE: selector id needed for tagged units only const resultUnits = [ @@ -207,7 +207,7 @@ function getUnits(): unknown { export async function reinstate(): boolean { if (!rampReady) return; - if (ActivePage.get() === "test" && !TestUI.resultVisible) { + if (ActivePage.get() === "test" && !TestState.resultVisible) { ramp.destroyUnits("all"); return; } diff --git a/frontend/src/ts/test/pace-caret.ts b/frontend/src/ts/test/pace-caret.ts index a3f367c66195..196d623e2303 100644 --- a/frontend/src/ts/test/pace-caret.ts +++ b/frontend/src/ts/test/pace-caret.ts @@ -1,5 +1,4 @@ import * as TestWords from "./test-words"; -import * as TestUI from "./test-ui"; import Config from "../config"; import * as DB from "../db"; import * as SlowTimer from "../states/slow-timer"; @@ -146,7 +145,7 @@ export async function init(): Promise { } export async function update(expectedStepEnd: number): Promise { - if (settings === null || !TestState.isActive || TestUI.resultVisible) { + if (settings === null || !TestState.isActive || TestState.resultVisible) { return; } // if ($("#paceCaret").hasClass("hidden")) { diff --git a/frontend/src/ts/test/result.ts b/frontend/src/ts/test/result.ts index 75c68380bf2b..52c5a9789b0e 100644 --- a/frontend/src/ts/test/result.ts +++ b/frontend/src/ts/test/result.ts @@ -44,6 +44,7 @@ import { Language } from "@monkeytype/schemas/languages"; import { canQuickRestart as canQuickRestartFn } from "../utils/quick-restart"; import { LocalStorageWithSchema } from "../utils/local-storage-with-schema"; import { z } from "zod"; +import * as TestState from "./test-state"; let result: CompletedEvent; let maxChartVal: number; @@ -57,7 +58,7 @@ let quoteId = ""; export function toggleSmoothedBurst(): void { useSmoothedBurst = !useSmoothedBurst; Notifications.add(useSmoothedBurst ? "on" : "off", 1); - if (TestUI.resultVisible) { + if (TestState.resultVisible) { void updateGraph().then(() => { ChartController.result.update("resize"); }); @@ -67,7 +68,7 @@ export function toggleSmoothedBurst(): void { export function toggleUserFakeChartData(): void { useFakeChartData = !useFakeChartData; Notifications.add(useFakeChartData ? "on" : "off", 1); - if (TestUI.resultVisible) { + if (TestState.resultVisible) { void updateGraph().then(() => { ChartController.result.update("resize"); }); @@ -1314,7 +1315,7 @@ $(".pageTest #favoriteQuoteButton").on("click", async () => { ConfigEvent.subscribe(async (eventKey) => { if ( ["typingSpeedUnit", "startGraphsAtZero"].includes(eventKey) && - TestUI.resultVisible + TestState.resultVisible ) { resultAnnotation = []; diff --git a/frontend/src/ts/test/test-logic.ts b/frontend/src/ts/test/test-logic.ts index 2e4b59ff3cf9..29e68874cac9 100644 --- a/frontend/src/ts/test/test-logic.ts +++ b/frontend/src/ts/test/test-logic.ts @@ -294,7 +294,7 @@ export function restart(options = {} as RestartOptions): void { TestUI.reset(); CompositionState.setComposing(false); - if (TestUI.resultVisible) { + if (TestState.resultVisible) { if (Config.randomTheme !== "off") { void ThemeController.randomizeTheme(); } @@ -306,14 +306,14 @@ export function restart(options = {} as RestartOptions): void { } let el = null; - if (TestUI.resultVisible) { + if (TestState.resultVisible) { //results are being displayed el = $("#result"); } else { //words are being displayed el = $("#typingTest"); } - TestUI.setResultVisible(false); + TestState.setResultVisible(false); TestState.setTestRestarting(true); el.stop(true, true).animate( { @@ -898,7 +898,7 @@ export async function finish(difficultyFailed = false): Promise { TestStats.setEnd(TestInput.keypressTimings.spacing.last); } - TestUI.setResultVisible(true); + TestState.setResultVisible(true); TestState.setActive(false); Replay.stopReplayRecording(); Caret.hide(); @@ -1304,7 +1304,7 @@ async function saveResult( void XPBar.update( snapxp, data.xp, - TestUI.resultVisible ? data.xpBreakdown : undefined + TestState.resultVisible ? data.xpBreakdown : undefined ); dataToSave.xp = data.xp; } diff --git a/frontend/src/ts/test/test-screenshot.ts b/frontend/src/ts/test/test-screenshot.ts index a2376c964a2d..9dbaaa5055c6 100644 --- a/frontend/src/ts/test/test-screenshot.ts +++ b/frontend/src/ts/test/test-screenshot.ts @@ -6,11 +6,11 @@ import { getActiveFunboxesWithFunction } from "./funbox/list"; import * as DB from "../db"; import * as ThemeColors from "../elements/theme-colors"; import { format } from "date-fns/format"; -import * as TestUI from "./test-ui"; import * as ActivePage from "../states/active-page"; import { getHtmlByUserFlags } from "../controllers/user-flag-controller"; import * as Notifications from "../elements/notifications"; import { convertRemToPixels } from "../utils/numbers"; +import * as TestState from "./test-state"; let revealReplay = false; let revertCookie = false; @@ -364,7 +364,7 @@ $(".pageTest").on("click", "#saveScreenshotButton", (event) => { }); $(document).on("keydown", (event) => { - if (!(TestUI.resultVisible && ActivePage.get() === "test")) return; + if (!(TestState.resultVisible && ActivePage.get() === "test")) return; if (event.key !== "Shift") return; $("#result #saveScreenshotButton i") .removeClass("far fa-image") @@ -372,7 +372,7 @@ $(document).on("keydown", (event) => { }); $(document).on("keyup", (event) => { - if (!(TestUI.resultVisible && ActivePage.get() === "test")) return; + if (!(TestState.resultVisible && ActivePage.get() === "test")) return; if (event.key !== "Shift") return; $("#result #saveScreenshotButton i") .removeClass("fas fa-download") diff --git a/frontend/src/ts/test/test-state.ts b/frontend/src/ts/test/test-state.ts index fff613d180ab..cc7c35d4fdcc 100644 --- a/frontend/src/ts/test/test-state.ts +++ b/frontend/src/ts/test/test-state.ts @@ -14,6 +14,7 @@ export let lineScrollDistance = 0; export let isLanguageRightToLeft = false; export let isDirectionReversed = false; export let testRestarting = false; +export let resultVisible = false; export function setRepeated(tf: boolean): void { isRepeated = tf; @@ -85,3 +86,7 @@ export function setTestRestarting(val: boolean): void { restartingResolve(); } } + +export function setResultVisible(val: boolean): void { + resultVisible = val; +} diff --git a/frontend/src/ts/test/test-ui.ts b/frontend/src/ts/test/test-ui.ts index bdbafef40ca8..0e3f478b2893 100644 --- a/frontend/src/ts/test/test-ui.ts +++ b/frontend/src/ts/test/test-ui.ts @@ -116,16 +116,11 @@ ConfigEvent.subscribe((eventKey, eventValue, nosave) => { if (eventKey === "burstHeatmap") void applyBurstHeatmap(); }); -export let resultVisible = false; export let activeWordTop = 0; export let lineTransition = false; export let currentTestLine = 0; export let resultCalculating = false; -export function setResultVisible(val: boolean): void { - resultVisible = val; -} - export function setActiveWordTop(val: number): void { activeWordTop = val; } @@ -331,7 +326,7 @@ async function joinOverlappingHints( async function updateHintsPosition(): Promise { if ( ActivePage.get() !== "test" || - resultVisible || + TestState.resultVisible || Config.indicateTypos !== "below" ) return; @@ -585,7 +580,7 @@ export async function centerActiveLine(): Promise { } export function updateWordsWrapperHeight(force = false): void { - if (ActivePage.get() !== "test" || resultVisible) return; + if (ActivePage.get() !== "test" || TestState.resultVisible) return; if (!force && Config.mode !== "custom") return; const wrapperEl = document.getElementById("wordsWrapper") as HTMLElement; const outOfFocusEl = document.querySelector( @@ -904,7 +899,7 @@ export async function scrollTape( noRemove = false, afterCompleteFn?: () => void ): Promise { - if (ActivePage.get() !== "test" || resultVisible) return; + if (ActivePage.get() !== "test" || TestState.resultVisible) return; await centeringActiveLine; @@ -1394,7 +1389,7 @@ async function loadWordsHistory(): Promise { } export function toggleResultWords(noAnimation = false): void { - if (resultVisible) { + if (TestState.resultVisible) { ResultWordHighlight.updateToggleWordsHistoryTime(); if ($("#resultWordsHistory").stop(true, true).hasClass("hidden")) { //show @@ -1699,7 +1694,7 @@ $(".pageTest #result #wpmChart").on("mouseenter", () => { }); $(".pageTest #resultWordsHistory").on("mouseenter", ".words .word", (e) => { - if (resultVisible) { + if (TestState.resultVisible) { const input = $(e.currentTarget).attr("input"); const burst = parseInt($(e.currentTarget).attr("burst") as string); if (input !== undefined) { @@ -1729,14 +1724,14 @@ addEventListener("resize", () => { $("#wordsInput").on("focus", (e) => { const wordsFocused = e.target === document.activeElement; if (!wordsFocused) return; - if (!resultVisible && Config.showOutOfFocusWarning) { + if (!TestState.resultVisible && Config.showOutOfFocusWarning) { OutOfFocus.hide(); } Caret.show(true); }); $("#wordsInput").on("focusout", () => { - if (!resultVisible && Config.showOutOfFocusWarning) { + if (!TestState.resultVisible && Config.showOutOfFocusWarning) { OutOfFocus.show(); } Caret.hide(); diff --git a/frontend/src/ts/ui.ts b/frontend/src/ts/ui.ts index 362d5e036b64..0b9c96e3a82b 100644 --- a/frontend/src/ts/ui.ts +++ b/frontend/src/ts/ui.ts @@ -98,7 +98,7 @@ window.addEventListener("beforeunload", (event) => { }); const debouncedEvent = debounce(250, () => { - if (getActivePage() === "test" && !TestUI.resultVisible) { + if (getActivePage() === "test" && !TestState.resultVisible) { if (Config.tapeMode !== "off") { void TestUI.scrollTape(); } else {