Added check that database is available before joining a game
Fixes issue with joining a game already in progress on a browser with indexedDB disabled
This commit is contained in:
parent
5df01973e5
commit
6c8833feae
@ -219,7 +219,6 @@ export function MapDataProvider({ children }) {
|
||||
}
|
||||
|
||||
async function getMapFromDB(mapId) {
|
||||
if (!database) return;
|
||||
return await database.table("maps").get(mapId);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import AuthModal from "../modals/AuthModal";
|
||||
|
||||
import AuthContext from "../contexts/AuthContext";
|
||||
import { MapStageProvider } from "../contexts/MapStageContext";
|
||||
import DatabaseContext from "../contexts/DatabaseContext";
|
||||
|
||||
import NetworkedMapAndTokens from "../network/NetworkedMapAndTokens";
|
||||
import NetworkedParty from "../network/NetworkedParty";
|
||||
@ -25,6 +26,7 @@ function Game() {
|
||||
password,
|
||||
setAuthenticationStatus,
|
||||
} = useContext(AuthContext);
|
||||
const { databaseStatus } = useContext(DatabaseContext);
|
||||
|
||||
// Handle authentication status
|
||||
useEffect(() => {
|
||||
@ -82,8 +84,11 @@ function Game() {
|
||||
|
||||
// Join game
|
||||
useEffect(() => {
|
||||
if (databaseStatus !== "loading") {
|
||||
console.log("join");
|
||||
session.joinParty(gameId, password);
|
||||
}, [gameId, password]);
|
||||
}
|
||||
}, [gameId, password, databaseStatus]);
|
||||
|
||||
// A ref to the Konva stage
|
||||
// the ref will be assigned in the MapInteraction component
|
||||
|
Loading…
Reference in New Issue
Block a user