Fixed party joining

This commit is contained in:
Mitchell McCaffrey 2020-11-26 18:54:11 +11:00
parent d231d9340e
commit 3fc8c98862

View File

@ -27,13 +27,11 @@ function Game() {
const { databaseStatus } = useContext(DatabaseContext); const { databaseStatus } = useContext(DatabaseContext);
const [session] = useState(new Session()); const [session] = useState(new Session());
const [offline, setOffline] = useState(false); const [offline, setOffline] = useState();
useEffect(() => { useEffect(() => {
async function connect() { async function connect() {
await session.connect(); await session.connect();
if (session.state === "offline") { setOffline(session.state === "offline");
setOffline(true);
}
} }
connect(); connect();
}, [session]); }, [session]);
@ -96,7 +94,7 @@ function Game() {
if (session.state === "online" && databaseStatus !== "loading") { if (session.state === "online" && databaseStatus !== "loading") {
session.joinParty(gameId, password); session.joinParty(gameId, password);
} }
}, [gameId, password, databaseStatus, session]); }, [gameId, password, databaseStatus, session, offline]);
// A ref to the Konva stage // A ref to the Konva stage
// the ref will be assigned in the MapInteraction component // the ref will be assigned in the MapInteraction component