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
4 changes: 2 additions & 2 deletions frontend/src/ts/controllers/challenge-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ export async function setup(challengeName: string): Promise<boolean> {
qs(".page.pageTest")?.show();

if (notitext === undefined) {
showNoticeNotification(`Challenge '${challenge.display}' loaded.`);
showSuccessNotification(`Challenge '${challenge.display}' loaded.`);
} else {
showNoticeNotification("Challenge loaded. " + notitext);
showSuccessNotification("Challenge loaded. " + notitext);
}
setLoadedChallenge(challenge);
challengeLoading = false;
Expand Down
29 changes: 13 additions & 16 deletions frontend/src/ts/controllers/url-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,35 +309,32 @@ export function loadTestSettingsFromUrl(getOverride?: string): void {
}
}

export function loadChallengeFromUrl(getOverride?: string): void {
export async function loadChallengeFromUrl(
getOverride?: string,
): Promise<void> {
const getValue = (
Misc.findGetParameter("challenge", getOverride) ?? ""
).toLowerCase();
if (getValue === "") return;

showNoticeNotification("Loading challenge");
ChallengeController.setup(getValue)
.then((result) => {
if (result) {
showSuccessNotification("Challenge loaded");
restartTest({
nosave: true,
});
}
})
.catch((e: unknown) => {
showErrorNotification("Failed to load challenge");
console.error(e);
const result = await ChallengeController.setup(getValue);
if (result) {
restartTest({
nosave: true,
});
}
}

authEvent.subscribe((event) => {
authEvent.subscribe(async (event) => {
if (event.type === "authStateChanged") {
const search = window.location.search;
const hash = window.location.hash;

await event.data.loadPromise;

loadCustomThemeFromUrl(search);
loadTestSettingsFromUrl(search);
loadChallengeFromUrl(search);
void loadChallengeFromUrl(search);
void linkDiscord(hash);
}
});
Loading