Skip to content

Commit

Permalink
Update map state machine
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr committed Feb 11, 2024
1 parent 8d09184 commit 72e5f96
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface IMapStateMachineContext {
isFiltering: boolean;
isShowingMapLayers: boolean;
activePimsPropertyIds: number[];
showDisposed: boolean;

requestFlyToLocation: (latlng: LatLngLiteral) => void;
requestFlyToBounds: (bounds: LatLngBounds) => void;
Expand All @@ -58,6 +59,7 @@ export interface IMapStateMachineContext {
setFilePropertyLocations: (locations: LatLngLiteral[]) => void;

setVisiblePimsProperties: (propertyIds: number[]) => void;
setShowDisposed: (show: boolean) => void;
}

const MapStateMachineContext = React.createContext<IMapStateMachineContext>(
Expand Down Expand Up @@ -252,6 +254,13 @@ export const MapStateMachineProvider: React.FC<React.PropsWithChildren<unknown>>
[serviceSend],
);

const setShowDisposed = useCallback(
(show: boolean) => {
serviceSend({ type: 'SET_SHOW_DISPOSED', show });
},
[serviceSend],
);

const toggleMapFilter = useCallback(() => {
serviceSend({ type: 'TOGGLE_FILTER' });
}, [serviceSend]);
Expand Down Expand Up @@ -301,6 +310,7 @@ export const MapStateMachineProvider: React.FC<React.PropsWithChildren<unknown>>
isFiltering: isFiltering,
isShowingMapLayers: isShowingMapLayers,
activePimsPropertyIds: state.context.activePimsPropertyIds,
showDisposed: state.context.showDisposed,

setMapSearchCriteria,
refreshMapProperties,
Expand All @@ -320,6 +330,7 @@ export const MapStateMachineProvider: React.FC<React.PropsWithChildren<unknown>>
toggleMapLayer,
setFilePropertyLocations,
setVisiblePimsProperties,
setShowDisposed,
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const featureViewStates = {
SET_VISIBLE_PROPERTIES: {
actions: assign({ activePimsPropertyIds: (_, event: any) => event.propertyIds }),
},
SET_SHOW_DISPOSED: {
actions: assign({ showDisposed: (_, event: any) => event.show }),
},
},
},
},
Expand Down Expand Up @@ -319,6 +322,7 @@ export const mapMachine = createMachine<MachineContext>({
mapFeatureData: emptyFeatureData,
filePropertyLocations: [],
activePimsPropertyIds: [],
showDisposed: false,
},

// State definitions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type MachineContext = {
requestedFlyTo: RequestedFlyTo;
filePropertyLocations: LatLngLiteral[];
activePimsPropertyIds: number[];
showDisposed: boolean;
};

// Possible state machine states
Expand Down

0 comments on commit 72e5f96

Please sign in to comment.