Skip to content

Commit

Permalink
[Maps] fix replaceLayerList to handle case where map is not intialized (
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Apr 2, 2020
1 parent ea53f5f commit 884c921
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions x-pack/legacy/plugins/maps/public/actions/map_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,16 @@ export function removeTrackedLayerStateForSelectedLayer() {

export function replaceLayerList(newLayerList) {
return (dispatch, getState) => {
getLayerListRaw(getState()).forEach(({ id }) => {
dispatch(removeLayerFromLayerList(id));
});
const isMapReady = getMapReady(getState());
if (!isMapReady) {
dispatch({
type: CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST,
});
} else {
getLayerListRaw(getState()).forEach(({ id }) => {
dispatch(removeLayerFromLayerList(id));
});
}

newLayerList.forEach(layerDescriptor => {
dispatch(addLayer(layerDescriptor));
Expand Down

0 comments on commit 884c921

Please sign in to comment.