Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions frontend/src/ts/commandline/lists/result-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand All @@ -69,7 +70,7 @@ const commands: Command[] = [
});
},
available: (): boolean => {
return TestUI.resultVisible;
return TestState.resultVisible;
},
},
{
Expand All @@ -78,7 +79,7 @@ const commands: Command[] = [
icon: "fa-exclamation-triangle",
subgroup: practiceSubgroup,
available: (): boolean => {
return TestUI.resultVisible;
return TestState.resultVisible;
},
},
{
Expand All @@ -89,7 +90,7 @@ const commands: Command[] = [
TestUI.toggleResultWords();
},
available: (): boolean => {
return TestUI.resultVisible;
return TestState.resultVisible;
},
},
{
Expand All @@ -103,7 +104,7 @@ const commands: Command[] = [
}, 500);
},
available: (): boolean => {
return TestUI.resultVisible;
return TestState.resultVisible;
},
},
{
Expand All @@ -117,7 +118,7 @@ const commands: Command[] = [
}, 500);
},
available: (): boolean => {
return TestUI.resultVisible;
return TestState.resultVisible;
},
},
{
Expand All @@ -141,7 +142,7 @@ const commands: Command[] = [
);
},
available: (): boolean => {
return TestUI.resultVisible;
return TestState.resultVisible;
},
},
];
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/ts/controllers/challenge-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -28,7 +27,7 @@ export function clearActive(): void {
if (
TestState.activeChallenge &&
!challengeLoading &&
!TestUI.testRestarting
!TestState.testRestarting
) {
Notifications.add("Challenge cleared", 0);
TestState.setActiveChallenge(null);
Expand Down
22 changes: 11 additions & 11 deletions frontend/src/ts/controllers/input-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ async function handleChar(
charIndex: number,
realInputValue?: string
): Promise<void> {
if (TestUI.resultCalculating || TestUI.resultVisible) {
if (TestUI.resultCalculating || TestState.resultVisible) {
return;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -870,7 +870,7 @@ $("#wordsInput").on("keydown", (event) => {
pageTestActive &&
!commandLineVisible &&
!popupVisible &&
!TestUI.resultVisible &&
!TestState.resultVisible &&
event.key !== "Enter" &&
!awaitingNextWord &&
TestState.testInitSuccess;
Expand Down Expand Up @@ -911,7 +911,7 @@ $(document).on("keydown", async (event) => {
pageTestActive &&
!commandLineVisible &&
!popupVisible &&
!TestUI.resultVisible &&
!TestState.resultVisible &&
(wordsFocused || event.key !== "Enter") &&
!awaitingNextWord;

Expand Down Expand Up @@ -983,7 +983,7 @@ $(document).on("keydown", async (event) => {
return;
}

if (TestUI.resultVisible) {
if (TestState.resultVisible) {
TestLogic.restart({
event,
});
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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) => {
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ts/controllers/pw-ad-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/ts/controllers/route-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ export async function navigate(
): Promise<void> {
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()})`
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/ts/test/pace-caret.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -146,7 +145,7 @@ export async function init(): Promise<void> {
}

export async function update(expectedStepEnd: number): Promise<void> {
if (settings === null || !TestState.isActive || TestUI.resultVisible) {
if (settings === null || !TestState.isActive || TestState.resultVisible) {
return;
}
// if ($("#paceCaret").hasClass("hidden")) {
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/ts/test/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
});
Expand All @@ -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");
});
Expand Down Expand Up @@ -1314,7 +1315,7 @@ $(".pageTest #favoriteQuoteButton").on("click", async () => {
ConfigEvent.subscribe(async (eventKey) => {
if (
["typingSpeedUnit", "startGraphsAtZero"].includes(eventKey) &&
TestUI.resultVisible
TestState.resultVisible
) {
resultAnnotation = [];

Expand Down
Loading
Loading