mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00

* 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
38 lines
1.2 KiB
Svelte
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} />
|