From fa4c684475a365055c2aacdf712c7903c9a5f2f2 Mon Sep 17 00:00:00 2001 From: Ilion Beyst Date: Mon, 22 Aug 2022 21:58:13 +0200 Subject: create editor store --- web/pw-server/src/routes/editor.svelte | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'web/pw-server/src/routes') 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);
@@ -137,7 +132,7 @@