diff options
author | Ilion Beyst <ilion.beyst@gmail.com> | 2022-08-22 21:58:13 +0200 |
---|---|---|
committer | Ilion Beyst <ilion.beyst@gmail.com> | 2022-08-22 21:58:13 +0200 |
commit | fa4c684475a365055c2aacdf712c7903c9a5f2f2 (patch) | |
tree | e42460b2c920dcf31e758757d34dbaba0c8d9051 /web/pw-server/src/lib/components | |
parent | 82ab9cef78020361d556f4208c57ecd9259d51ea (diff) | |
download | planetwars.dev-fa4c684475a365055c2aacdf712c7903c9a5f2f2.tar.xz planetwars.dev-fa4c684475a365055c2aacdf712c7903c9a5f2f2.zip |
create editor store
Diffstat (limited to 'web/pw-server/src/lib/components')
-rw-r--r-- | web/pw-server/src/lib/components/SubmitPane.svelte | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/web/pw-server/src/lib/components/SubmitPane.svelte b/web/pw-server/src/lib/components/SubmitPane.svelte index 82f752e..9fd2380 100644 --- a/web/pw-server/src/lib/components/SubmitPane.svelte +++ b/web/pw-server/src/lib/components/SubmitPane.svelte @@ -3,13 +3,14 @@ import { getBotName, saveBotName } from "$lib/bot_code"; import { currentUser } from "$lib/stores/current_user"; + import { selectedOpponent } from "$lib/stores/editor_state"; + import { createEventDispatcher, onMount } from "svelte"; import Select from "svelte-select"; export let editSession; let availableBots: object[] = []; - let selectedOpponent = undefined; let botName: string | undefined = undefined; // whether to show the "save succesful" message let saveSuccesful = false; @@ -27,14 +28,16 @@ if (res.ok) { availableBots = await res.json(); - selectedOpponent = availableBots.find((b) => b["name"] === "simplebot"); + if (!$selectedOpponent) { + selectedOpponent.set(availableBots.find((b) => b["name"] === "simplebot")); + } } }); const dispatch = createEventDispatcher(); async function submitBot() { - const opponentName = selectedOpponent["name"]; + const opponentName = $selectedOpponent["name"]; let response = await fetch("/api/submit_bot", { method: "POST", @@ -106,7 +109,7 @@ optionIdentifier="name" labelIdentifier="name" items={availableBots} - bind:value={selectedOpponent} + bind:value={$selectedOpponent} isClearable={false} /> </div> |