diff --git a/src/components/views/Gameroom.tsx b/src/components/views/Gameroom.tsx index 0b0fe2a..36db523 100644 --- a/src/components/views/Gameroom.tsx +++ b/src/components/views/Gameroom.tsx @@ -44,11 +44,14 @@ const Gameroom = () => { console.log(user) const [showReadyPopup, setShowReadyPopup] = useState(false); const [gameOver, setGameOver] = useState(false); + const gameOverRef = useRef(false); const [currentSpeakerID, setCurrentSpeakerID] = useState(null); const [playerLists, setPlayerLists] = useState([]); const roundFinished = useRef(false); const [endTime, setEndTime] = useState(null); - const gameTheme = useRef(null); + const gameTheme = useRef("Loading...."); + const leaderboardInfoRecieved = useRef(false); + const [leaderboardInfo, setLeaderboardInfo] = useState([]); const [gameInfo, setGameInfo] = useState(null); const gameInfoRef = useRef(null); @@ -161,6 +164,10 @@ const Gameroom = () => { console.log(roundFinished.current); } } + if (gameOverRef.current === true && leaderboardInfoRecieved.current === false){ + setLeaderboardInfo(payloadData.message); + leaderboardInfoRecieved.current = true; + } }; const onGameInfoReceived = (payload) => { @@ -182,6 +189,7 @@ const Gameroom = () => { setShowReadyPopup(true); } else if (payloadData.message.gameStatus === "over") { setShowReadyPopup(false); + gameOverRef.current = true; setGameOver(true); } else { setShowReadyPopup(false); @@ -464,60 +472,67 @@ const Gameroom = () => { console.log(playerLists); const LeaderBoard = ({ playerStatus }) => { + // console.log("123456") + console.log("[LeaderBoard]",playerStatus) + return ( -