Wip : Lobby

This commit is contained in:
2024-06-13 10:00:29 -04:00
parent 8a3e2babc9
commit 4a56f3ed62
4 changed files with 28 additions and 11 deletions
+8 -2
View File
@@ -9,12 +9,17 @@ const config = useRuntimeConfig()
const route = useRoute()
const gameId = route.params.id
const { data: game, pending, error, refresh } = await useFetch<Game>(
const { data: game, pending, error, refresh } = (await useFetch<Game>(
new URL(`/games/${gameId}`, config.public.endpoint).href,
{
credentials: "include",
}
);
))
// as { data: Ref<Game>, pending: Ref<Boolean>, error: Ref<Error>, refresh: (opts?: unknown | undefined) => Promise<void> }
if (game.value == null) {
throw new Error()
}
const eventSource = subscribe(`/games/${gameId}/subscribe`)
@@ -24,6 +29,7 @@ eventSource.addEventListener("message", (message) => {
const authStore = useAuthStore()
const isSpectator = computed(() => authStore.logged && game.value.teams.every(t => t.players.every(p => p.user.userId !== authStore.selfUser.userId)))
// const current_players = computed<Array<Player>>(() => Array.from(goStore.current_game?.players ?? []).filter(p => p.team === goStore.current_game?.current_turn))