Anki/ts/change-notetype/index.ts
Henrik Giesel 51af6b2544 Rename i18n and i18n_helpers to i18n-generated and i18n
- This way, we can restrict the awkwardness of importing files outside
  the ts directory within lib
2021-10-02 23:34:03 +02:00

37 lines
1.2 KiB
TypeScript

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
/* eslint
@typescript-eslint/no-explicit-any: "off",
*/
import { ChangeNotetypeState, getChangeNotetypeInfo, getNotetypeNames } from "./lib";
import { setupI18n, tr } from "../lib/i18n";
import { checkNightMode } from "../lib/nightmode";
import ChangeNotetypePage from "./ChangeNotetypePage.svelte";
import { nightModeKey } from "../components/context-keys";
export async function changeNotetypePage(
target: HTMLDivElement,
oldNotetypeId: number,
newNotetypeId: number
): Promise<ChangeNotetypePage> {
const [info, names] = await Promise.all([
getChangeNotetypeInfo(oldNotetypeId, newNotetypeId),
getNotetypeNames(),
setupI18n({
modules: [tr.ModuleName.ACTIONS, tr.ModuleName.CHANGE_NOTETYPE],
}),
]);
const nightMode = checkNightMode();
const context = new Map();
context.set(nightModeKey, nightMode);
const state = new ChangeNotetypeState(names, info);
return new ChangeNotetypePage({
target,
props: { state },
context,
} as any);
}