refactor: read selected locale inside session store

This commit is contained in:
neilchen0812 committed 2026-10-09 17:12:28 +10:30
1 parent 5e8d3f275d
commit a7039714aa
3 files changed
+6 -4

No files matched your search

+1 -1
View File
@@ -35,7 +35,7 @@ const reset = async () => {
return return
} }
await sessionStore.createSession(selectedLocale) await sessionStore.createSession()
} catch (error) { } catch (error) {
console.error('Failed to reset quest:', error) console.error('Failed to reset quest:', error)
toast.error(t('game.reset_failed')) toast.error(t('game.reset_failed'))
+2 -2
View File
@@ -4,7 +4,7 @@ import { useToast } from 'vue-toastification'
import { computed } from 'vue' import { computed } from 'vue'
import { useSession } from '../../store/session' import { useSession } from '../../store/session'
const { t, locale } = useI18n() const { t } = useI18n()
const toast = useToast() const toast = useToast()
const sessionStore = useSession() const sessionStore = useSession()
@@ -13,7 +13,7 @@ const showCover = computed(() => sessionStore.session === null)
const startSession = async () => { const startSession = async () => {
try { try {
await sessionStore.createSession(locale.value) await sessionStore.createSession()
} catch (err: any) { } catch (err: any) {
console.error(err) console.error(err)
toast.error(err.message) toast.error(err.message)
+3 -1
View File
@@ -10,6 +10,7 @@ import Socket from '../utils/socket'
import SocketTerminal from '../utils/terminal' import SocketTerminal from '../utils/terminal'
import type { Session } from '../types' import type { Session } from '../types'
import { trpc } from '../utils/trpc' import { trpc } from '../utils/trpc'
import { i18n } from '../i18n'
const socket = new Socket() const socket = new Socket()
const term = new SocketTerminal() const term = new SocketTerminal()
@@ -65,7 +66,8 @@ export const useSession = defineStore('session', {
) )
term.focus() term.focus()
}, },
async createSession(locale: QuestLocale) { async createSession() {
const locale = i18n.global.locale.value
const session = await trpc.session.createSession.mutate({ const session = await trpc.session.createSession.mutate({
questId: this.questId, questId: this.questId,
locale, locale,