mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
use getState
This commit is contained in:
parent
1ce305620d
commit
36a0e0dcc7
2 changed files with 30 additions and 10 deletions
|
|
@ -14,13 +14,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
import { onMount } from "svelte";
|
||||
import { tr, zoomFactor } from "./stores";
|
||||
import Start from "./Start.svelte";
|
||||
import ErrorState from "./ErrorState.svelte";
|
||||
import Normal from "./Normal.svelte";
|
||||
import Uninstall from "./Uninstall.svelte";
|
||||
import { launcherOsUnsupported } from "@generated/ftl";
|
||||
|
||||
const { data }: PageProps = $props();
|
||||
|
||||
const langs = data.langs;
|
||||
const options = $state(data.options);
|
||||
let mirrors = $state(data.mirrors);
|
||||
let langs = $state(data.langs);
|
||||
let selectedLang = $state(data.userLocale);
|
||||
let flow = $state(data.state);
|
||||
let mirrors = $state(data.mirrors);
|
||||
|
||||
async function onLangChange(lang: string) {
|
||||
await setLang({ val: lang });
|
||||
|
|
@ -39,6 +43,22 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
});
|
||||
|
||||
onMount(() => windowReady({}));
|
||||
|
||||
let footer: any = $state(null);
|
||||
|
||||
const uninstall = () => {
|
||||
flow.case = "uninstall";
|
||||
};
|
||||
</script>
|
||||
|
||||
<Start bind:selectedLang {langs} {options} {mirrors} />
|
||||
<Start bind:selectedLang {langs} {footer}>
|
||||
{#if flow.case === "normal"}
|
||||
<Normal {mirrors} options={flow.value.options!} {uninstall} bind:footer />
|
||||
{:else if flow.case === "uninstall"}
|
||||
<Uninstall bind:footer />
|
||||
{:else if flow.case === "osUnsupported" }
|
||||
<ErrorState title={$tr.launcherOsUnsupported()} detail={flow.value} bind:footer />
|
||||
{:else if flow.case === "unknownError" }
|
||||
<ErrorState title={$tr.launcherUnknownError()} detail={flow.value} bind:footer />
|
||||
{/if}
|
||||
</Start>
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
// Copyright: Ankitects Pty Ltd and contributors
|
||||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
|
||||
import { getLangs, getMirrors, getOptions } from "@generated/backend-launcher";
|
||||
import { getLangs, getMirrors, getState } from "@generated/backend-launcher";
|
||||
import { ModuleName, setupI18n } from "@tslib/i18n";
|
||||
import type { PageLoad } from "./$types";
|
||||
|
||||
export const load = (async () => {
|
||||
const i18nPromise = setupI18n({ modules: [ModuleName.LAUNCHER] }, true);
|
||||
const langsPromise = getLangs({});
|
||||
const optionsPromise = getOptions({});
|
||||
const statePromise = getState({});
|
||||
const mirrorsPromise = getMirrors({});
|
||||
|
||||
const [_, { userLocale, langs }, options, { mirrors }] = await Promise.all([
|
||||
const [_, { userLocale, langs }, { kind: state }, { mirrors }] = await Promise.all([
|
||||
i18nPromise,
|
||||
langsPromise,
|
||||
optionsPromise,
|
||||
mirrorsPromise,
|
||||
statePromise,
|
||||
mirrorsPromise
|
||||
]);
|
||||
|
||||
return { langs, userLocale, options, mirrors };
|
||||
return { langs, userLocale, state, mirrors };
|
||||
}) satisfies PageLoad;
|
||||
|
|
|
|||
Loading…
Reference in a new issue