Refactoring map, place state where it belongs
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good

This commit is contained in:
Willem Dantuma
2020-02-20 21:20:50 +01:00
parent f82125a486
commit abfef73cd1
3 changed files with 55 additions and 96 deletions

View File

@@ -55,7 +55,8 @@ export interface State {
selectedBaseLayer: IItemLayer,
selectedOverlayLayer: IItemLayer,
styles:IStyles,
showLayerSwitcher:boolean
showLayerSwitcher:boolean,
setStateCount:number
}
export const initialState: State = {
@@ -90,7 +91,8 @@ export const initialState: State = {
selectedOverlayLayer: null,
selectedItemLayer: null,
styles: {},
showLayerSwitcher: false
showLayerSwitcher: false,
setStateCount: 0
}
export function reducer(state = initialState, action: mapActions.Actions | commonActions.Actions | RouterNavigationAction): State {
@@ -102,16 +104,16 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
case mapActions.SETMAPSTATE: {
let a = action as mapActions.SetMapState;
return tassign(state, {
mapState: a.mapState
mapState: a.mapState,setStateCount: state.setStateCount+1
});
}
case mapActions.SETQUERYSTATE: {
let a = action as mapActions.SetQueryState;
return tassign(state, { queryState: tassign(a.queryState )});
return tassign(state, { queryState: tassign(a.queryState ),setStateCount: state.setStateCount+1});
}
case mapActions.SETSTATE: {
let a = action as mapActions.SetState;
return tassign(state, { mapState: tassign(a.mapState), queryState: tassign(a.queryState)});
return tassign(state, { mapState: tassign(a.mapState), queryState: tassign(a.queryState),setStateCount: state.setStateCount+1});
}
case mapActions.SETVIEWEXTENT: {
let a = action as mapActions.SetViewExtent;
@@ -337,6 +339,9 @@ export function reducer(state = initialState, action: mapActions.Actions | commo
let a = action as mapActions.ShowLayerSwitcher;
return tassign(state,{showLayerSwitcher:a.show});
}
case mapActions.INIT:{
return tassign(state,{setStateCount:0});
}
default: {
return state;
}
@@ -365,6 +370,7 @@ export const getSelectedItemLayer = (state: State) => state.selectedItemLayer;
export const getPeriod = (state:State) => state.period;
export const getStyles = (state:State) => state.styles;
export const getShowLayerSwitcher = (state:State) => state.showLayerSwitcher;
export const getSetStateCount = (state:State) => state.setStateCount;
export const selectMapState = createFeatureSelector<State>(MODULE_NAME);
export const selectGetMapState= createSelector(selectMapState, getMapState);
@@ -389,5 +395,6 @@ export const selectGetSelectedItemLayer = createSelector(selectMapState, getSele
export const selectGetPeriod = createSelector(selectMapState, getPeriod);
export const selectGetStyles = createSelector(selectMapState, getStyles);
export const selectGetShowLayerSwitcher = createSelector(selectMapState,getShowLayerSwitcher);
export const selectgetSetStateCount = createSelector(selectMapState,getSetStateCount);