Anki/ts/routes/deck-options/[deckId]/+page.svelte
Arthur Milchior d7fc98d4d8
Deck options without bridge (#3571)
* NF: Modify CONTRIBUTORS

Just so that I stop getting the warning

* NF: Create `deckOptionsReady`

* NF: rename _close to require_close

The method will have to be used outside of this class, so can't be private

* NF: simplify slightly some code

* NF: remove bridge command from deck options

* Remove unused import

* Remove superfluous comment with a typo
2025-01-08 21:30:30 +11:00

38 lines
1.2 KiB
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import * as tr from "@generated/ftl";
import { onMount } from "svelte";
import DeckOptionsPage from "../DeckOptionsPage.svelte";
import { commitEditing } from "../lib";
import type { PageData } from "./$types";
import { deckOptionsRequireClose, deckOptionsReady } from "@generated/backend";
export let data: PageData;
let page: DeckOptionsPage;
globalThis.anki ||= {};
globalThis.anki.deckOptionsPendingChanges = async (): Promise<void> => {
await commitEditing();
if (
!(await data.state.isModified()) ||
confirm(tr.cardTemplatesDiscardChanges())
) {
// Either there was no change, or the user accepted to discard the changes.
deckOptionsRequireClose({});
}
};
onMount(() => {
globalThis.$deckOptions = new Promise((resolve, _reject) => {
resolve(page);
});
data.state.resolveOriginalConfigs();
deckOptionsReady({});
});
</script>
<DeckOptionsPage state={data.state} bind:this={page} />