From 6d37bdd6b2f5272cacaace60cfd14e0847b0096a Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sun, 11 Aug 2024 20:48:01 +0900
Subject: feat(frontend): obtain `problem` from `Game` object instead of
 `prepare` message's  payload

---
 frontend/app/components/GolfPlayApp.client.tsx | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

(limited to 'frontend/app/components/GolfPlayApp.client.tsx')

diff --git a/frontend/app/components/GolfPlayApp.client.tsx b/frontend/app/components/GolfPlayApp.client.tsx
index 43828e6..70c463f 100644
--- a/frontend/app/components/GolfPlayApp.client.tsx
+++ b/frontend/app/components/GolfPlayApp.client.tsx
@@ -11,7 +11,6 @@ import GolfPlayAppWaiting from "./GolfPlayApps/GolfPlayAppWaiting";
 type WebSocketMessage = components["schemas"]["GamePlayerMessageS2C"];
 
 type Game = components["schemas"]["Game"];
-type Problem = components["schemas"]["Problem"];
 
 type GameState = "connecting" | "waiting" | "starting" | "gaming" | "finished";
 
@@ -32,8 +31,6 @@ export default function GolfPlayApp({
 
 	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);
@@ -105,8 +102,6 @@ export default function GolfPlayApp({
 			if (lastJsonMessage !== null) {
 				console.log(lastJsonMessage.type);
 				if (lastJsonMessage.type === "player:s2c:prepare") {
-					const { problem } = lastJsonMessage.data;
-					setProblem(problem);
 					console.log("player:c2s:ready");
 					sendJsonMessage({ type: "player:c2s:ready" });
 				} else if (lastJsonMessage.type === "player:s2c:start") {
@@ -148,7 +143,8 @@ export default function GolfPlayApp({
 	} else if (gameState === "gaming") {
 		return (
 			<GolfPlayAppGaming
-				problem={problem!.description}
+				problemTitle={game.problem.title}
+				problemDescription={game.problem.description}
 				onCodeChange={onCodeChange}
 				onCodeSubmit={onCodeSubmit}
 				currentScore={currentScore}
-- 
cgit v1.3.1

