fix(commandline): languages sometimes didnt load in time, showing an error

This commit is contained in:
Miodec 2024-03-20 23:11:09 +01:00
parent e551e043af
commit c0500ce9c6
2 changed files with 14 additions and 3 deletions

View file

@ -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 = {
@ -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";

View file

@ -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);