Skip to content

Commit be2d830

Browse files
authored
fix: failed to fetch commandline when a version/hotfix is deployed (@fehmer) (monkeytypegame#6507)
1 parent 4cca580 commit be2d830

File tree

6 files changed

+12
-42
lines changed

6 files changed

+12
-42
lines changed

frontend/src/ts/event-handlers/footer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Config, * as UpdateConfig from "../config";
22
import { isAuthenticated } from "../firebase";
33
import * as DB from "../db";
44
import * as Notifications from "../elements/notifications";
5-
import { getCommandline } from "../utils/async-modules";
5+
import * as Commandline from "../commandline/commandline";
66
import * as SupportPopup from "../modals/support";
77
import * as ContactModal from "../modals/contact";
88
import * as VersionHistoryModal from "../modals/version-history";
@@ -11,7 +11,7 @@ import { envConfig } from "../constants/env-config";
1111
document
1212
.querySelector("footer #commandLineMobileButton")
1313
?.addEventListener("click", async () => {
14-
(await getCommandline()).show({
14+
Commandline.show({
1515
singleListOverride: false,
1616
});
1717
});
@@ -54,7 +54,7 @@ document
5454
UpdateConfig.setCustomTheme(true);
5555
} else {
5656
const subgroup = Config.customTheme ? "customThemesList" : "themes";
57-
(await getCommandline()).show({
57+
Commandline.show({
5858
subgroupOverride: subgroup,
5959
});
6060
}

frontend/src/ts/event-handlers/global.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Misc from "../utils/misc";
22
import * as PageTransition from "../states/page-transition";
33
import Config from "../config";
44
import * as TestWords from "../test/test-words";
5-
import { getCommandline } from "../utils/async-modules";
5+
import * as Commandline from "../commandline/commandline";
66
import * as Notifications from "../elements/notifications";
77

88
document.addEventListener("keydown", async (e) => {
@@ -24,7 +24,7 @@ document.addEventListener("keydown", async (e) => {
2424
e.preventDefault();
2525
const popupVisible = Misc.isAnyPopupVisible();
2626
if (!popupVisible) {
27-
(await getCommandline()).show();
27+
Commandline.show();
2828
}
2929
}
3030
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { getCommandline } from "../utils/async-modules";
1+
import * as Commandline from "../commandline/commandline";
22

33
$("#keymap").on("click", ".r5 .layoutIndicator", async () => {
4-
(await getCommandline()).show({
4+
Commandline.show({
55
subgroupOverride: "keymapLayouts",
66
});
77
});

frontend/src/ts/event-handlers/test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getCommandline } from "../utils/async-modules";
1+
import * as Commandline from "../commandline/commandline";
22
import * as CustomWordAmount from "../modals/custom-word-amount";
33
import Config from "../config";
44
import * as DB from "../db";
@@ -18,13 +18,13 @@ import { getMode2 } from "../utils/misc";
1818
$(".pageTest").on("click", "#testModesNotice .textButton", async (event) => {
1919
const attr = $(event.currentTarget).attr("commands");
2020
if (attr === undefined) return;
21-
(await getCommandline()).show({ subgroupOverride: attr });
21+
Commandline.show({ subgroupOverride: attr });
2222
});
2323

2424
$(".pageTest").on("click", "#testModesNotice .textButton", async (event) => {
2525
const attr = $(event.currentTarget).attr("commandId");
2626
if (attr === undefined) return;
27-
(await getCommandline()).show({ commandOverride: attr });
27+
Commandline.show({ commandOverride: attr });
2828
});
2929

3030
$(".pageTest").on("click", "#testConfig .wordCount .textButton", (e) => {

frontend/src/ts/modals/support.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import AnimatedModal from "../utils/animated-modal";
2-
import { getCommandline } from "../utils/async-modules";
2+
import * as Commandline from "../commandline/commandline";
33

44
export function show(): void {
55
void modal.show();
@@ -9,8 +9,7 @@ const modal = new AnimatedModal({
99
dialogId: "supportModal",
1010
setup: async (modalEl): Promise<void> => {
1111
modalEl.querySelector("button.ads")?.addEventListener("click", async () => {
12-
const commandline = await getCommandline();
13-
commandline.show(
12+
Commandline.show(
1413
{ subgroupOverride: "enableAds" },
1514
{
1615
modalChain: modal,

frontend/src/ts/utils/async-modules.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,6 @@ import * as Notifications from "../elements/notifications";
33
import { createErrorMessage } from "./misc";
44
import * as Skeleton from "../utils/skeleton";
55

6-
Skeleton.save("commandLine");
7-
8-
export async function getCommandline(): Promise<
9-
typeof import("../commandline/commandline.js")
10-
> {
11-
try {
12-
Loader.show();
13-
// eslint-disable-next-line import/no-unresolved
14-
const module = await import("../commandline/commandline.js");
15-
Loader.hide();
16-
return module;
17-
} catch (e) {
18-
Loader.hide();
19-
if (
20-
e instanceof Error &&
21-
e.message.includes("Failed to fetch dynamically imported module")
22-
) {
23-
Notifications.add(
24-
"Failed to load commandline module: could not fetch",
25-
-1
26-
);
27-
} else {
28-
const msg = createErrorMessage(e, "Failed to load commandline module");
29-
Notifications.add(msg, -1);
30-
}
31-
throw e;
32-
}
33-
}
34-
356
Skeleton.save("devOptionsModal");
367

378
export async function getDevOptionsModal(): Promise<

0 commit comments

Comments
 (0)