diff options
Diffstat (limited to 'web/pw-server/src')
-rw-r--r-- | web/pw-server/src/routes/matches/[match_id].svelte | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/web/pw-server/src/routes/matches/[match_id].svelte b/web/pw-server/src/routes/matches/[match_id].svelte index 25438ad..b3d9f01 100644 --- a/web/pw-server/src/routes/matches/[match_id].svelte +++ b/web/pw-server/src/routes/matches/[match_id].svelte @@ -25,6 +25,7 @@ import PlayerLog from "$lib/components/PlayerLog.svelte"; import Select from "svelte-select"; import { PLAYER_COLORS } from "$lib/constants"; + import { currentUser } from "$lib/stores/current_user"; export let matchLog: string | undefined; export let matchData: object; @@ -42,20 +43,38 @@ playerId: index + 1, // stoopid player number + 1 label: player["bot_name"], })); + + // TODO: refactor match logs so that users can no longer get match logs for other players. + function currentUserCanSeeStdErr(matchPlayer: object): boolean { + if (!matchPlayer["owner_id"]) { + return true; + } + + console.log(matchPlayer, $currentUser); + return matchPlayer["owner_id"] === $currentUser?.["user_id"]; + } + + $: showStdErr = + !!selectedPlayer && currentUserCanSeeStdErr(matchData["players"][selectedPlayer["value"]]); </script> <div class="container"> <Visualizer {matchLog} {matchData} /> <div class="output-pane"> <div class="player-select"> - <Select items={matchPlayerSelectItems} clearable={false} bind:value={selectedPlayer}> + <Select + items={matchPlayerSelectItems} + clearable={false} + searchable={false} + bind:value={selectedPlayer} + > <div slot="item" let:item> <span style:color={item.color}>{item.label}</span> </div> </Select> </div> <div class="player-log"> - <PlayerLog {matchLog} playerId={selectedPlayer?.playerId} /> + <PlayerLog {matchLog} playerId={selectedPlayer?.playerId} {showStdErr} /> </div> </div> </div> |