From f19e0a3d0bf19ae473bfbf97b80f128f4c5fda7e Mon Sep 17 00:00:00 2001 From: lshw54 Date: Sun, 26 Apr 2026 13:02:29 +0800 Subject: [PATCH] fix(AccountList): auto-start game after login when setting enabled (#246) When 'Launch game after login' (autoStartGame) is checked in Settings, the game now automatically starts after the first successful account list load. Mirrors WPF loginWorker_RunWorkerCompleted L1421-1429. Uses a one-shot flag so retry / game-switch don't re-trigger. --- src/pages/AccountList.vue | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/pages/AccountList.vue b/src/pages/AccountList.vue index cad3dc3..ae192e2 100644 --- a/src/pages/AccountList.vue +++ b/src/pages/AccountList.vue @@ -122,6 +122,7 @@ import { useAuthStore } from '../stores/auth' import { useAccountStore } from '../stores/account' import { useConfigStore } from '../stores/config' import { useGameStore, gameCodeOf, imageUrl } from '../stores/game' +import { useUiStore } from '../stores/ui' import { commands, type LoginRegion, type ServiceAccount } from '../types/bindings' import { CommandInvocationError, @@ -156,6 +157,14 @@ const account = useAccountStore() * not a generic settings object). */ const configStore = useConfigStore() +const ui = useUiStore() + +/* + * One-shot flag: auto-start game on the first successful loadList + * after mount. Cleared after first use so retry / game-switch + * don't re-trigger. + */ +let pendingAutoStart = true /* * D8 — game store wire-in. Aliased to `game` (matching the * `account` / `auth` / `configStore` alias style used above). @@ -222,6 +231,16 @@ async function loadList(): Promise { } loadState.value = 'ready' + + // Auto-start game after first load if the setting is enabled. + // Mirrors WPF `loginWorker_RunWorkerCompleted` L1421-1429. + // Only fires once per mount (not on retry / game switch). + if (pendingAutoStart) { + pendingAutoStart = false + if (ui.autoStartGame && account.serviceAccounts.length > 0) { + void handleStartGame() + } + } } catch (err) { /* * `account.getServiceAccounts` funnels through `wrapCommand`,