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/routes/editor.svelte | |
parent | 82ab9cef78020361d556f4208c57ecd9259d51ea (diff) | |
download | planetwars.dev-fa4c684475a365055c2aacdf712c7903c9a5f2f2.tar.xz planetwars.dev-fa4c684475a365055c2aacdf712c7903c9a5f2f2.zip |
create editor store
Diffstat (limited to 'web/pw-server/src/routes/editor.svelte')
-rw-r--r-- | web/pw-server/src/routes/editor.svelte | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/web/pw-server/src/routes/editor.svelte b/web/pw-server/src/routes/editor.svelte index 33217d5..b1644c8 100644 --- a/web/pw-server/src/routes/editor.svelte +++ b/web/pw-server/src/routes/editor.svelte @@ -2,26 +2,22 @@ import Visualizer from "$lib/components/Visualizer.svelte"; import EditorView from "$lib/components/EditorView.svelte"; import { onMount } from "svelte"; - import { DateTime } from "luxon"; import type { Ace } from "ace-builds"; import ace from "ace-builds/src-noconflict/ace?client"; import * as AcePythonMode from "ace-builds/src-noconflict/mode-python?client"; - import { getBotCode, saveBotCode, hasBotCode } from "$lib/bot_code"; + import { getBotCode, saveBotCode } from "$lib/bot_code"; + import { matchHistory } from "$lib/stores/editor_state"; import { debounce } from "$lib/utils"; import SubmitPane from "$lib/components/SubmitPane.svelte"; import OutputPane from "$lib/components/OutputPane.svelte"; - import RulesView from "$lib/components/RulesView.svelte"; - import Leaderboard from "$lib/components/Leaderboard.svelte"; enum ViewMode { Editor, MatchVisualizer, } - let matches = []; - let viewMode = ViewMode.Editor; let selectedMatchId: string | undefined = undefined; let selectedMatchLog: string | undefined = undefined; @@ -47,8 +43,7 @@ async function onMatchCreated(e: CustomEvent) { const matchData = e.detail["match"]; - matches.unshift(matchData); - matches = matches; + matchHistory.pushMatch(matchData); await selectMatch(matchData["id"]); } @@ -123,7 +118,7 @@ } } - $: selectedMatch = matches.find((m) => m["id"] === selectedMatchId); + $: selectedMatch = $matchHistory.find((m) => m["id"] === selectedMatchId); </script> <div class="container"> @@ -137,7 +132,7 @@ </div> <div class="sidebar-header">match history</div> <ul class="match-list"> - {#each matches as match} + {#each $matchHistory as match} <li class="match-card sidebar-item" on:click={() => selectMatch(match.id)} |