Skip to content

Commit

Permalink
dont write kml shapes to localstorage - not enough room there
Browse files Browse the repository at this point in the history
  • Loading branch information
micheal-w-wells committed Mar 18, 2024
1 parent 56363d0 commit a3f1017
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions appv2/src/state/reducers/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ function createMapReducer(configuration: AppConfig): (MapState, AnyAction) => Ma
break;
}
case INIT_SERVER_BOUNDARIES_GET: {
const withLocalToggles = action.payload.data.map((incomingItem) => {
const withLocalToggles = action.payload.data?.map((incomingItem) => {
let returnVal = { ...incomingItem };
const existingToggleVal = draftState.serverBoundaries.find((oldItem) => {
oldItem.id === incomingItem;
Expand All @@ -711,14 +711,24 @@ function createMapReducer(configuration: AppConfig): (MapState, AnyAction) => Ma
return returnVal;
});
draftState.serverBoundaries = withLocalToggles;
localStorage.setItem('serverLayersConf', JSON.stringify(draftState.serverBoundaries));
const strippedOfShapes = draftState.serverBoundaries.map((item) => {
const returnVal = { ...item };
delete returnVal.geojson
return returnVal
})
localStorage.setItem('serverLayersConf', JSON.stringify(strippedOfShapes));
break;
}
case TOGGLE_KML_LAYER: {
const index = draftState.serverBoundaries.findIndex((layer) => layer.id === action.payload.layer.id);
console.log(index);
draftState.serverBoundaries[index].toggle = !draftState.serverBoundaries[index].toggle;
localStorage.setItem('serverLayersConf', JSON.stringify(draftState.serverBoundaries));
const strippedOfShapes = draftState.serverBoundaries.map((item) => {
const returnVal = { ...item };
delete returnVal.geojson
return returnVal
})
localStorage.setItem('serverLayersConf', JSON.stringify(strippedOfShapes));
break;
}
case USER_SETTINGS_SET_RECORDSET: {
Expand Down

0 comments on commit a3f1017

Please sign in to comment.