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) {
|
async function getMapFromDB(mapId) {
|
||||||
if (!database) return;
|
|
||||||
return await database.table("maps").get(mapId);
|
return await database.table("maps").get(mapId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import AuthModal from "../modals/AuthModal";
|
|||||||
|
|
||||||
import AuthContext from "../contexts/AuthContext";
|
import AuthContext from "../contexts/AuthContext";
|
||||||
import { MapStageProvider } from "../contexts/MapStageContext";
|
import { MapStageProvider } from "../contexts/MapStageContext";
|
||||||
|
import DatabaseContext from "../contexts/DatabaseContext";
|
||||||
|
|
||||||
import NetworkedMapAndTokens from "../network/NetworkedMapAndTokens";
|
import NetworkedMapAndTokens from "../network/NetworkedMapAndTokens";
|
||||||
import NetworkedParty from "../network/NetworkedParty";
|
import NetworkedParty from "../network/NetworkedParty";
|
||||||
@ -25,6 +26,7 @@ function Game() {
|
|||||||
password,
|
password,
|
||||||
setAuthenticationStatus,
|
setAuthenticationStatus,
|
||||||
} = useContext(AuthContext);
|
} = useContext(AuthContext);
|
||||||
|
const { databaseStatus } = useContext(DatabaseContext);
|
||||||
|
|
||||||
// Handle authentication status
|
// Handle authentication status
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -82,8 +84,11 @@ function Game() {
|
|||||||
|
|
||||||
// Join game
|
// Join game
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (databaseStatus !== "loading") {
|
||||||
|
console.log("join");
|
||||||
session.joinParty(gameId, password);
|
session.joinParty(gameId, password);
|
||||||
}, [gameId, password]);
|
}
|
||||||
|
}, [gameId, password, databaseStatus]);
|
||||||
|
|
||||||
// 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user