[Maps] Clear data load error when layer gets correct data (#34484) (#34740)

This commit is contained in:
Thomas Neirynck 2019-04-22 17:02:10 -04:00 committed by GitHub
parent b2c0d456fe
commit 23af014b05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 17 deletions

View file

@ -136,12 +136,13 @@ export function addLayer(layerDescriptor) {
};
}
export function setLayerErrorStatus(layerId, errorMessage) {
function setLayerDataLoadErrorStatus(layerId, errorMessage) {
return dispatch => {
dispatch({
type: SET_LAYER_ERROR_STATUS,
isInErrorState: errorMessage !== null,
layerId,
errorMessage,
errorMessage
});
};
}
@ -366,14 +367,20 @@ export function updateSourceDataRequest(layerId, newData) {
}
export function endDataLoad(layerId, dataId, requestToken, data, meta) {
return ({
type: LAYER_DATA_LOAD_ENDED,
layerId,
dataId,
data,
meta,
requestToken
});
return async (dispatch) => {
dispatch({
type: LAYER_DATA_LOAD_ENDED,
layerId,
dataId,
data,
meta,
requestToken
});
//Clear any data-load errors when there is a succesful data return.
//Co this on end-data-load iso at start-data-load to avoid blipping the error status between true/false.
//This avoids jitter in the warning icon of the TOC when the requests continues to return errors.
dispatch(setLayerDataLoadErrorStatus(layerId, null));
};
}
export function onDataLoadError(layerId, dataId, requestToken, errorMessage) {
@ -385,7 +392,7 @@ export function onDataLoadError(layerId, dataId, requestToken, errorMessage) {
requestToken,
});
dispatch(setLayerErrorStatus(layerId, errorMessage));
dispatch(setLayerDataLoadErrorStatus(layerId, errorMessage));
};
}

View file

@ -12,8 +12,7 @@ import {
mapDestroyed,
setMouseCoordinates,
clearMouseCoordinates,
clearGoto,
setLayerErrorStatus,
clearGoto
} from '../../../actions/store_actions';
import { getLayerList, getMapReady, getGoto } from "../../../selectors/map_selectors";
@ -46,9 +45,7 @@ function mapDispatchToProps(dispatch) {
},
clearGoto: () => {
dispatch(clearGoto());
},
setLayerErrorStatus: (id, msg) =>
dispatch(setLayerErrorStatus(id, msg))
}
};
}

View file

@ -158,7 +158,7 @@ export function map(state = INITIAL_STATE, action) {
...layerList.slice(0, layerIdx),
{
...layerList[layerIdx],
__isInErrorState: true,
__isInErrorState: action.isInErrorState,
__errorMessage: action.errorMessage
},
...layerList.slice(layerIdx + 1)