diff --git a/src/actions/LandOwnershipActions.js b/src/actions/LandOwnershipActions.js index 2857642c..a96e2e0d 100644 --- a/src/actions/LandOwnershipActions.js +++ b/src/actions/LandOwnershipActions.js @@ -1,4 +1,12 @@ import { getRequest } from "./RequestActions"; +import { autoSave } from './MapActions'; + +export const togglePropertyDisplay = () => { + return dispatch => { + dispatch({ type: "TOGGLE_PROPERTY_DISPLAY" }); + return dispatch(autoSave()); + }; +} export const highlightProperty = (property) => { return (dispatch) => { diff --git a/src/actions/MapActions.js b/src/actions/MapActions.js index 03544f4d..6f2edccc 100644 --- a/src/actions/MapActions.js +++ b/src/actions/MapActions.js @@ -140,6 +140,7 @@ export const saveCurrentMap = ( mapLayers: { landDataLayers: getState().mapLayers.landDataLayers, myDataLayers: getState().dataGroups.activeGroups, + ownershipDisplay: getState().landOwnership.displayActive, }, version: VERSION, name: saveName, diff --git a/src/components/left-pane/LeftPaneLandData.js b/src/components/left-pane/LeftPaneLandData.js index 4bf5af57..f6f59b21 100644 --- a/src/components/left-pane/LeftPaneLandData.js +++ b/src/components/left-pane/LeftPaneLandData.js @@ -5,6 +5,7 @@ import LeftPaneToggle from "./LeftPaneToggle"; import Draggable from "./Draggable"; import LandDataLayerToggle from "./LandDataLayerToggle"; import { toggleDataGroup } from "../../actions/DataGroupActions"; +import { togglePropertyDisplay } from "../../actions/LandOwnershipActions"; const DataLayersContainer = ({ children, title }) => { const [expanded, setExpanded] = useState(true); @@ -120,7 +121,7 @@ const LeftPaneLandData = ({ open, active, onClose }) => { dispatch({ type: "TOGGLE_PROPERTY_DISPLAY" })} + onToggle={() => dispatch(togglePropertyDisplay())} /> diff --git a/src/reducers/LandOwnershipReducer.js b/src/reducers/LandOwnershipReducer.js index 32fecda5..0c97cefc 100644 --- a/src/reducers/LandOwnershipReducer.js +++ b/src/reducers/LandOwnershipReducer.js @@ -50,6 +50,13 @@ export default (state = INITIAL_STATE, action) => { ...state, activePropertyId: null }; + case 'LOAD_MAP': + // this could be undefined for old maps + const displayActive = action.payload.data.mapLayers.ownershipDisplay || false; + return { + ...state, + displayActive + } default: return state; }