Skip to content

Commit

Permalink
fix(commandline): languages sometimes didnt load in time, showing an …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
Miodec committed Mar 20, 2024
1 parent e551e04 commit c0500ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion frontend/src/ts/commandline/commandline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as Notifications from "../elements/notifications";
import * as OutOfFocus from "../test/out-of-focus";
import * as ActivePage from "../states/active-page";
import { focusWords } from "../test/test-ui";
import * as Loader from "../elements/loader";

type CommandlineMode = "search" | "input";
type InputModeParams = {
Expand Down Expand Up @@ -77,9 +78,11 @@ export function show(
settings.subgroupOverride
);
if (exists) {
subgroupOverride = CommandlineLists.getList(
Loader.show();
subgroupOverride = await CommandlineLists.getList(
settings.subgroupOverride as CommandlineLists.ListsObjectKeys
);
Loader.hide();
} else {
subgroupOverride = null;
usingSingleList = Config.singleListCommandLine === "on";
Expand Down
12 changes: 10 additions & 2 deletions frontend/src/ts/commandline/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,9 +501,17 @@ export function doesListExist(listName: string): boolean {
return lists[listName as ListsObjectKeys] !== undefined;
}

export function getList(
export async function getList(
listName: ListsObjectKeys
): MonkeyTypes.CommandsSubgroup {
): Promise<MonkeyTypes.CommandsSubgroup> {
await Promise.allSettled([
layoutsPromise,
languagesPromise,
funboxPromise,
fontsPromise,
themesPromise,
challengesPromise,
]);
const list = lists[listName];
if (!list) {
Notifications.add(`List not found: ${listName}`, -1);
Expand Down

0 comments on commit c0500ce

Please sign in to comment.