From 551c7327da9d3d34095c0199b16eef05da2ff4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20=27birdy=27=20Danjou?= Date: Wed, 6 Dec 2023 02:27:41 +0100 Subject: [PATCH] fix() navigation between contract --- src/modules/game/components/Game/Game.tsx | 4 ++-- src/modules/game/components/WaitingRoom/WaitingRoom.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/game/components/Game/Game.tsx b/src/modules/game/components/Game/Game.tsx index 1e5f0cb..8c431bd 100644 --- a/src/modules/game/components/Game/Game.tsx +++ b/src/modules/game/components/Game/Game.tsx @@ -37,11 +37,11 @@ export const Game = ({ account, provider }: GameProps) => { setContractLoading(false); }; - if (!contractLoading && !contract) { + if (!contractLoading && contractAddress) { setContractLoading(true); void getContract(contractAddress!); } - }, [contractAddress]); + }, [contractAddress, provider]); useEffect(() => { const refreshPlayers = async () => { diff --git a/src/modules/game/components/WaitingRoom/WaitingRoom.tsx b/src/modules/game/components/WaitingRoom/WaitingRoom.tsx index 2eb03cc..0829159 100644 --- a/src/modules/game/components/WaitingRoom/WaitingRoom.tsx +++ b/src/modules/game/components/WaitingRoom/WaitingRoom.tsx @@ -41,8 +41,10 @@ export const WaitingRoom = ({ contract, account, players, currentName = '' }: Wa setMinPlayers(await contract.MIN_PLAYERS()); setMaxPlayers(await contract.MAX_PLAYERS()); }; - void refreshInformations(); - }, [contract]); + if (account) { + void refreshInformations(); + } + }, [contract, account]); const startGame = async () => { const startTx = await contract.start();