Wip : Lobby
This commit is contained in:
+8
-2
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user