diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-07-29 23:30:52 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-07-29 23:30:52 +0900 |
| commit | 7720afcdc383632f7672d355456909f78be1e948 (patch) | |
| tree | 643d35876c7c9f31861f56d376fa340641d39972 | |
| parent | 00623621557ed6722c045145b6a28748ec9a5c4a (diff) | |
| download | iosdc-japan-2024-albatross-7720afcdc383632f7672d355456909f78be1e948.tar.gz iosdc-japan-2024-albatross-7720afcdc383632f7672d355456909f78be1e948.tar.zst iosdc-japan-2024-albatross-7720afcdc383632f7672d355456909f78be1e948.zip | |
fix: problem not available in watching page
| -rw-r--r-- | backend/api/handlers.go | 16 | ||||
| -rw-r--r-- | frontend/app/components/GolfWatchApp.client.tsx | 5 |
2 files changed, 10 insertions, 11 deletions
diff --git a/backend/api/handlers.go b/backend/api/handlers.go index c4810a0..273f68a 100644 --- a/backend/api/handlers.go +++ b/backend/api/handlers.go @@ -145,8 +145,8 @@ func (h *ApiHandler) GetGames(ctx context.Context, request GetGamesRequestObject } func (h *ApiHandler) GetGamesGameId(ctx context.Context, request GetGamesGameIdRequestObject) (GetGamesGameIdResponseObject, error) { - // TODO: user permission - // user := ctx.Value("user").(*auth.JWTClaims) + user := ctx.Value("user").(*auth.JWTClaims) + // TODO: check user permission gameId := request.GameId row, err := h.q.GetGameById(ctx, int32(gameId)) if err != nil { @@ -158,14 +158,16 @@ func (h *ApiHandler) GetGamesGameId(ctx context.Context, request GetGamesGameIdR startedAt = &startedAtTimestamp } var problem *Problem - if row.ProblemID != nil && GameState(row.State) != Closed && GameState(row.State) != WaitingEntries { + if row.ProblemID != nil { if row.Title == nil || row.Description == nil { panic("inconsistent data") } - problem = &Problem{ - ProblemId: int(*row.ProblemID), - Title: *row.Title, - Description: *row.Description, + if user.IsAdmin || (GameState(row.State) != Closed && GameState(row.State) != WaitingEntries) { + problem = &Problem{ + ProblemId: int(*row.ProblemID), + Title: *row.Title, + Description: *row.Description, + } } } game := Game{ diff --git a/frontend/app/components/GolfWatchApp.client.tsx b/frontend/app/components/GolfWatchApp.client.tsx index 00ad005..a76f2c9 100644 --- a/frontend/app/components/GolfWatchApp.client.tsx +++ b/frontend/app/components/GolfWatchApp.client.tsx @@ -10,7 +10,6 @@ import GolfWatchAppFinished from "./GolfWatchApps/GolfWatchAppFinished"; type WebSocketMessage = components["schemas"]["GameWatcherMessageS2C"]; type Game = components["schemas"]["Game"]; -type Problem = components["schemas"]["Problem"]; type GameState = "connecting" | "waiting" | "starting" | "gaming" | "finished"; @@ -34,8 +33,6 @@ export default function GolfWatchApp({ const [gameState, setGameState] = useState<GameState>("connecting"); - const [problem, setProblem] = useState<Problem | null>(null); - const [startedAt, setStartedAt] = useState<number | null>(null); const [timeLeftSeconds, setTimeLeftSeconds] = useState<number | null>(null); @@ -127,7 +124,7 @@ export default function GolfWatchApp({ } else if (gameState === "gaming") { return ( <GolfWatchAppGaming - problem={problem!.description} + problem={game.problem!.description} codeA={codeA} scoreA={scoreA} codeB={codeB} |
