Skip to content
Open
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
7 changes: 7 additions & 0 deletions frontend/src/ts/controllers/page-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getActivePage,
setActivePage,
setSelectedProfileName,
setTestPageVisible,
} from "../states/core";
import * as Settings from "../pages/settings";
import * as Account from "../pages/account";
Expand Down Expand Up @@ -241,6 +242,9 @@ export async function change(
});
previousPage.element.hide();
await previousPage?.afterHide();
if (previousPage?.id === "test") {
setTestPageVisible(false);
}

// we need to evaluate and store next page loading mode in case options.loadingOptions.loadingMode is sync
const nextPageLoadingMode = nextPage.loadingOptions?.loadingMode();
Expand Down Expand Up @@ -291,6 +295,9 @@ export async function change(
setActivePage(nextPage.id);
updateOpenGraphUrl();
Focus.set(false);
if (nextPage.id === "test") {
setTestPageVisible(true);
}

//next page
await nextPage?.beforeShow({
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/ts/states/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ export const isAuthenticated = (): boolean => getUserId() !== null;
export const [getSelectedProfileName, setSelectedProfileName] = createSignal<
string | undefined
>(undefined);

export const [isTestPageVisible, setTestPageVisible] = createSignal(
getActivePage() === "test",
);
8 changes: 6 additions & 2 deletions frontend/src/ts/test/test-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import * as TodayTracker from "./today-tracker";
import * as ChallengeContoller from "../controllers/challenge-controller";
import { clearQuoteStats } from "../states/quote-rate";
import * as Result from "./result";
import { getActivePage, isAuthenticated } from "../states/core";
import {
getActivePage,
isAuthenticated,
isTestPageVisible,
} from "../states/core";
import {
setResultVisible,
setWordsHaveNewline,
Expand Down Expand Up @@ -423,7 +427,7 @@ async function init(): Promise<boolean> {
return await init();
}

if (getActivePage() === "test") {
if (isTestPageVisible()) {
await Funbox.activate();
}

Expand Down
Loading