From f9c1ec2d9b6239963aac00d51963312fe17185af Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Tue, 11 Aug 2020 18:48:48 +1000 Subject: [PATCH] Fixed bug with map state being would be wrongly synced to party members --- src/components/map/SelectMapButton.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/map/SelectMapButton.js b/src/components/map/SelectMapButton.js index 6b0d296..7bf63b8 100644 --- a/src/components/map/SelectMapButton.js +++ b/src/components/map/SelectMapButton.js @@ -5,6 +5,7 @@ import SelectMapModal from "../../modals/SelectMapModal"; import SelectMapIcon from "../../icons/SelectMapIcon"; import MapDataContext from "../../contexts/MapDataContext"; +import AuthContext from "../../contexts/AuthContext"; function SelectMapButton({ onMapChange, @@ -16,8 +17,11 @@ function SelectMapButton({ const [isModalOpen, setIsModalOpen] = useState(false); const { updateMapState } = useContext(MapDataContext); + const { userId } = useContext(AuthContext); function openModal() { - currentMapState && updateMapState(currentMapState.mapId, currentMapState); + if (currentMapState && currentMap && currentMap.owner === userId) { + updateMapState(currentMapState.mapId, currentMapState); + } setIsModalOpen(true); }