From 1e6df136d8202c8adf65948527f4c3e7583b338c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 4 Mar 2025 22:55:01 +0900 Subject: websocket to polling --- .../GolfWatchApps/GolfWatchAppGaming.tsx | 31 +++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx') diff --git a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx index 7cfbc86..afb8bfe 100644 --- a/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx +++ b/frontend/app/components/GolfWatchApps/GolfWatchAppGaming.tsx @@ -1,12 +1,7 @@ import { useAtomValue } from "jotai"; import { - codeAAtom, - codeBAtom, gamingLeftTimeSecondsAtom, - scoreAAtom, - scoreBAtom, - submitResultAAtom, - submitResultBAtom, + latestGameStatesAtom, } from "../../states/watch"; import type { PlayerProfile } from "../../types/PlayerProfile"; import BorderedContainer from "../BorderedContainer"; @@ -33,12 +28,16 @@ export default function GolfWatchAppGaming({ gameResult, }: Props) { const leftTimeSeconds = useAtomValue(gamingLeftTimeSecondsAtom)!; - const codeA = useAtomValue(codeAAtom); - const codeB = useAtomValue(codeBAtom); - const scoreA = useAtomValue(scoreAAtom); - const scoreB = useAtomValue(scoreBAtom); - const submitResultA = useAtomValue(submitResultAAtom); - const submitResultB = useAtomValue(submitResultBAtom); + const latestGameStates = useAtomValue(latestGameStatesAtom); + + const stateA = latestGameStates[playerProfileA.id]!; + const codeA = stateA.code; + const scoreA = stateA.score; + const statusA = stateA.status; + const stateB = latestGameStates[playerProfileB.id]!; + const codeB = stateB.code; + const scoreB = stateB.score; + const statusB = stateB.status; const leftTime = (() => { const m = Math.floor(leftTimeSeconds / 60); @@ -109,11 +108,11 @@ export default function GolfWatchAppGaming({ bgB="bg-purple-400" />
- +
- - + +
@@ -122,7 +121,7 @@ export default function GolfWatchAppGaming({ {problemDescription}
- +
); -- cgit v1.2.3-70-g09d2