fix(frontend): restore default session context store in vertical slice
All checks were successful
CI / test-and-quality (push) Successful in 2m0s
CI / test-and-quality (pull_request) Successful in 2m31s

This commit is contained in:
2026-03-01 13:24:46 +00:00
parent b52896d137
commit 85e970b90c
2 changed files with 51 additions and 24 deletions

View File

@@ -1,18 +1,15 @@
import type { ApiClient } from '../api/client';
import type { SessionDetailResponse } from '../api/types';
import {
createSessionContextStore,
type SessionContext,
type SessionContextInput,
type SessionContextStore as PersistedSessionContextStore
} from './session-context-store';
export type AsyncState = 'idle' | 'loading' | 'success' | 'error';
export interface SessionContext {
sessionCode: string;
playerToken: string;
nickname: string;
}
export interface SessionContextStore {
get(): SessionContext | null;
set(context: SessionContext): void;
}
export type SessionContextStore = Pick<PersistedSessionContextStore, 'get' | 'set'>;
export interface VerticalSliceState {
sessionCode: string;
@@ -30,14 +27,9 @@ export interface VerticalSliceController {
startRound(sessionCode: string, categorySlug: string): Promise<VerticalSliceState>;
}
const NOOP_SESSION_CONTEXT_STORE: SessionContextStore = {
get: () => null,
set: () => undefined
};
export function createVerticalSliceController(
api: ApiClient,
sessionContextStore: SessionContextStore = NOOP_SESSION_CONTEXT_STORE
sessionContextStore: SessionContextStore = createSessionContextStore()
): VerticalSliceController {
const persistedContext = sessionContextStore.get();
@@ -96,11 +88,12 @@ export function createVerticalSliceController(
state.joinState = 'success';
state.sessionCode = normalizeCode(join.data.session.code || requestCode);
sessionContextStore.set({
const nextContext: SessionContextInput = {
sessionCode: state.sessionCode,
playerToken: join.data.player.session_token,
nickname: join.data.player.nickname
});
playerId: join.data.player.id,
token: join.data.player.session_token
};
sessionContextStore.set(nextContext);
return hydrateLobby(state.sessionCode);
}
@@ -131,3 +124,5 @@ export function createVerticalSliceController(
startRound
};
}
export type { SessionContext };