Fixed bug with map state being would be wrongly synced to party members

This commit is contained in:
Mitchell McCaffrey 2020-08-11 18:48:48 +10:00
parent e99e4e9f0f
commit f9c1ec2d9b

View File

@ -5,6 +5,7 @@ import SelectMapModal from "../../modals/SelectMapModal";
import SelectMapIcon from "../../icons/SelectMapIcon"; import SelectMapIcon from "../../icons/SelectMapIcon";
import MapDataContext from "../../contexts/MapDataContext"; import MapDataContext from "../../contexts/MapDataContext";
import AuthContext from "../../contexts/AuthContext";
function SelectMapButton({ function SelectMapButton({
onMapChange, onMapChange,
@ -16,8 +17,11 @@ function SelectMapButton({
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const { updateMapState } = useContext(MapDataContext); const { updateMapState } = useContext(MapDataContext);
const { userId } = useContext(AuthContext);
function openModal() { function openModal() {
currentMapState && updateMapState(currentMapState.mapId, currentMapState); if (currentMapState && currentMap && currentMap.owner === userId) {
updateMapState(currentMapState.mapId, currentMapState);
}
setIsModalOpen(true); setIsModalOpen(true);
} }