From 3fc8c98862fc9442a949480216af081595ecf05c Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 26 Nov 2020 18:54:11 +1100 Subject: [PATCH] Fixed party joining --- src/routes/Game.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/routes/Game.js b/src/routes/Game.js index 84d75f4..93535d9 100644 --- a/src/routes/Game.js +++ b/src/routes/Game.js @@ -27,13 +27,11 @@ function Game() { const { databaseStatus } = useContext(DatabaseContext); const [session] = useState(new Session()); - const [offline, setOffline] = useState(false); + const [offline, setOffline] = useState(); useEffect(() => { async function connect() { await session.connect(); - if (session.state === "offline") { - setOffline(true); - } + setOffline(session.state === "offline"); } connect(); }, [session]); @@ -96,7 +94,7 @@ function Game() { if (session.state === "online" && databaseStatus !== "loading") { session.joinParty(gameId, password); } - }, [gameId, password, databaseStatus, session]); + }, [gameId, password, databaseStatus, session, offline]); // A ref to the Konva stage // the ref will be assigned in the MapInteraction component