From 8c9cf497baf2572212016864714631514a2def87 Mon Sep 17 00:00:00 2001 From: rogup Date: Tue, 12 Dec 2023 16:15:28 +0000 Subject: [PATCH 1/2] Autosave ownership layer display --- src/actions/MapActions.js | 1 + src/components/left-pane/LeftPaneLandData.js | 3 ++- src/reducers/LandOwnershipReducer.js | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) 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; } From 14a5359d85fb0c23903fb492e6f9dedb8a7d9ef3 Mon Sep 17 00:00:00 2001 From: rogup Date: Tue, 12 Dec 2023 16:23:12 +0000 Subject: [PATCH 2/2] Add Redux thunk --- src/actions/LandOwnershipActions.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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) => {