feat: improve reconnect, add ESLint configuration for common and socket

This commit is contained in:
Ralex
2025-10-19 00:37:26 +02:00
parent 8bdb8f47ef
commit 96bff164c0
36 changed files with 1571 additions and 677 deletions

View File

@@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
import { Player } from "@rahoot/common/types/game"
import { StatusDataMap } from "@rahoot/common/types/game/status"
import { createStatus, Status } from "@rahoot/web/utils/createStatus"
@@ -9,22 +8,26 @@ type ManagerStore<T> = {
status: Status<T>
players: Player[]
setGameId: (gameId: string | null) => void
setStatus: <K extends keyof T>(name: K, data: T[K]) => void
setGameId: (_gameId: string | null) => void
setStatus: <K extends keyof T>(_name: K, _data: T[K]) => void
resetStatus: () => void
setPlayers: (_players: Player[]) => void
setPlayers: (players: Player[]) => void
reset: () => void
}
const initialStatus = createStatus<StatusDataMap, "SHOW_ROOM">("SHOW_ROOM", {
text: "Waiting for the players",
})
export const useManagerStore = create<ManagerStore<StatusDataMap>>((set) => ({
const initialState = {
gameId: null,
status: initialStatus,
players: [],
}
export const useManagerStore = create<ManagerStore<StatusDataMap>>((set) => ({
...initialState,
setGameId: (gameId) => set({ gameId }),
@@ -32,4 +35,6 @@ export const useManagerStore = create<ManagerStore<StatusDataMap>>((set) => ({
resetStatus: () => set({ status: initialStatus }),
setPlayers: (players) => set({ players }),
reset: () => set(initialState),
}))