fix onDataLoadEnd and onDataLoadError event handler callbacks only called for source data requests (#134786)

* fix onDataLoadEnd and onDataLoadError event handler callbacks only called for source data requests

* dataLoadEnd

Co-authored-by: Liza Katz <liza.katz@elastic.co>
This commit is contained in:
Nathan Reese 2022-06-23 06:59:51 -06:00 committed by GitHub
parent be71c903b9
commit 501927443a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -287,27 +287,27 @@ function endDataLoad(
throw new DataRequestAbortError();
}
if (dataId === SOURCE_DATA_REQUEST_ID) {
const features = data && 'features' in data ? (data as FeatureCollection).features : [];
const layer = getLayerById(layerId, getState());
const features = data && 'features' in data ? (data as FeatureCollection).features : [];
const layer = getLayerById(layerId, getState());
const eventHandlers = getEventHandlers(getState());
if (eventHandlers && eventHandlers.onDataLoadEnd) {
const resultMeta: ResultMeta = {};
if (layer && layer.getType() === LAYER_TYPE.GEOJSON_VECTOR) {
const featuresWithoutCentroids = features.filter((feature) => {
return feature.properties ? !feature.properties[KBN_IS_CENTROID_FEATURE] : true;
});
resultMeta.featuresCount = featuresWithoutCentroids.length;
}
eventHandlers.onDataLoadEnd({
layerId,
dataId,
resultMeta,
const eventHandlers = getEventHandlers(getState());
if (eventHandlers && eventHandlers.onDataLoadEnd) {
const resultMeta: ResultMeta = {};
if (layer && layer.getType() === LAYER_TYPE.GEOJSON_VECTOR) {
const featuresWithoutCentroids = features.filter((feature) => {
return feature.properties ? !feature.properties[KBN_IS_CENTROID_FEATURE] : true;
});
resultMeta.featuresCount = featuresWithoutCentroids.length;
}
eventHandlers.onDataLoadEnd({
layerId,
dataId,
resultMeta,
});
}
if (dataId === SOURCE_DATA_REQUEST_ID) {
if (layer) {
dispatch(updateTooltipStateForLayer(layer, features));
}
@ -343,16 +343,16 @@ function onDataLoadError(
) => {
dispatch(unregisterCancelCallback(requestToken));
if (dataId === SOURCE_DATA_REQUEST_ID) {
const eventHandlers = getEventHandlers(getState());
if (eventHandlers && eventHandlers.onDataLoadError) {
eventHandlers.onDataLoadError({
layerId,
dataId,
errorMessage,
});
}
const eventHandlers = getEventHandlers(getState());
if (eventHandlers && eventHandlers.onDataLoadError) {
eventHandlers.onDataLoadError({
layerId,
dataId,
errorMessage,
});
}
if (dataId === SOURCE_DATA_REQUEST_ID) {
const layer = getLayerById(layerId, getState());
if (layer) {
dispatch(updateTooltipStateForLayer(layer));