feat: sync active room players

This commit is contained in:
metamethods 2025-01-03 01:23:11 -08:00
parent 0a947d8bdd
commit 6a49c361a0

View File

@ -12,6 +12,7 @@
let { room }: { room: Room } = $props();
let roomTimer = $state(room.secondsRemaining);
let players = $state(room.players);
onMount(() => {
if (!room.finished) {
@ -29,7 +30,9 @@
.get<Room>(`/api/room/${room.roomId}`)
.then((result) => result.data);
roomTimer = updatedRoom.secondsRemaining;
players = updatedRoom.players;
if (updatedRoom.finished) {
console.log('killing invervals');
clearInterval(roomTimerUpdateInterval);
clearInterval(roomTimerSyncInterval);
}
@ -69,7 +72,7 @@
</p>
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 sm:grid-rows-2">
{#each room.players as player}
{#each players as player}
<Player {player} />
{/each}
</div>