Updated type to match backend

This commit is contained in:
martin 2023-09-24 15:48:46 +02:00
parent a17ff36719
commit 2f71b7ffc5

View File

@ -105,17 +105,15 @@ function joinGame(data?: PlayerProps[]): void { // TODO missing data when refres
store.set(playersAtom, playerProps.map(p => new Player(p))); store.set(playersAtom, playerProps.map(p => new Player(p)));
} }
type ReadyData = { allReady: boolean, players: PlayerProps[] } | string; type ReadyData = { allReady: boolean, players: PlayerProps[] };
function ready(data?: ReadyData): void { function ready(data?: ReadyData): void {
if (data && typeof data !== "string") { if (data) {
const players = data.players.map(p => new Player(p)); const players = data.players.map(p => new Player(p));
store.set(playersAtom, players); store.set(playersAtom, players);
if (data.allReady) { if (data.allReady) {
store.set(currentPlayerNameAtom, data.players[0].username); store.set(currentPlayerNameAtom, data.players[0].username);
} }
} else {
console.error("Error:", data);
} }
} }