From 9a16c14b7fde683eb41526085c15852c69bed5e5 Mon Sep 17 00:00:00 2001 From: HsiangNianian Date: Sun, 18 Jan 2026 13:05:29 +0800 Subject: refactor: move version refresh logic to App.svelte and clean up GameState constructor --- ui/src/stores/game.svelte.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'ui/src/stores') diff --git a/ui/src/stores/game.svelte.ts b/ui/src/stores/game.svelte.ts index 15dcf22..504d108 100644 --- a/ui/src/stores/game.svelte.ts +++ b/ui/src/stores/game.svelte.ts @@ -9,29 +9,24 @@ export class GameState { selectedVersion = $state(""); constructor() { - // Refresh versions when active instance changes - $effect(() => { - if (instancesState.activeInstanceId) { - this.loadVersions(); - } else { - this.versions = []; - } - }); + // Constructor intentionally empty + // Instance switching handled in App.svelte with $effect } get latestRelease() { return this.versions.find((v) => v.type === "release"); } - async loadVersions() { - if (!instancesState.activeInstanceId) { + async loadVersions(instanceId?: string) { + const id = instanceId || instancesState.activeInstanceId; + if (!id) { this.versions = []; return; } try { this.versions = await invoke("get_versions", { - instanceId: instancesState.activeInstanceId, + instanceId: id, }); // Don't auto-select version here - let BottomBar handle version selection // based on installed versions only -- cgit v1.2.3-70-g09d2