Added check for map state in map state network update

This commit is contained in:
Mitchell McCaffrey 2020-10-30 11:57:36 +11:00
parent 04dceef022
commit c743901962

View File

@ -365,31 +365,31 @@ function NetworkedMapAndTokens({ session }) {
putToken(newToken);
}
}
if (id === "tokenStateEdit") {
if (id === "tokenStateEdit" && currentMapState) {
setCurrentMapState((prevMapState) => ({
...prevMapState,
tokens: { ...prevMapState.tokens, ...data },
}));
}
if (id === "tokenStateRemove") {
if (id === "tokenStateRemove" && currentMapState) {
setCurrentMapState((prevMapState) => ({
...prevMapState,
tokens: omit(prevMapState.tokens, Object.keys(data)),
}));
}
if (id === "mapDraw") {
if (id === "mapDraw" && currentMapState) {
addMapDrawActions(data, "mapDrawActionIndex", "mapDrawActions");
}
if (id === "mapDrawIndex") {
if (id === "mapDrawIndex" && currentMapState) {
setCurrentMapState((prevMapState) => ({
...prevMapState,
mapDrawActionIndex: data,
}));
}
if (id === "mapFog") {
if (id === "mapFog" && currentMapState) {
addMapDrawActions(data, "fogDrawActionIndex", "fogDrawActions");
}
if (id === "mapFogIndex") {
if (id === "mapFogIndex" && currentMapState) {
setCurrentMapState((prevMapState) => ({
...prevMapState,
fogDrawActionIndex: data,