mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Maps] ensure url has been resolved before syncing (#30750)
This commit is contained in:
parent
53ddf51b60
commit
6bf127e107
3 changed files with 28 additions and 5 deletions
|
@ -118,10 +118,25 @@ export function setLayerErrorStatus(layerId, errorMessage) {
|
|||
}
|
||||
|
||||
export function toggleLayerVisible(layerId) {
|
||||
return {
|
||||
type: TOGGLE_LAYER_VISIBLE,
|
||||
layerId
|
||||
return async (dispatch, getState) => {
|
||||
//if the current-state is invisible, we also want to sync data
|
||||
//e.g. if a layer was invisible at start-up, it won't have any data loaded
|
||||
const layer = getLayerList(getState()).find(layer => {
|
||||
return layerId === layer.getId();
|
||||
});
|
||||
if (!layer) {
|
||||
return;
|
||||
}
|
||||
const makeVisible = !layer.isVisible();
|
||||
await dispatch({
|
||||
type: TOGGLE_LAYER_VISIBLE,
|
||||
layerId
|
||||
});
|
||||
if (makeVisible) {
|
||||
dispatch(syncDataForLayer(layerId));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export function setSelectedLayer(layerId) {
|
||||
|
|
|
@ -107,8 +107,6 @@ export const getRefreshConfig = ({ map }) => map.mapState.refreshConfig;
|
|||
|
||||
export const getRefreshTimerLastTriggeredAt = ({ map }) => map.mapState.refreshTimerLastTriggeredAt;
|
||||
|
||||
export const getMetadata = ({ config }) => config && config.meta;
|
||||
|
||||
export const getDataFilters = createSelector(
|
||||
getMapExtent,
|
||||
getMapBuffer,
|
||||
|
|
|
@ -34,6 +34,10 @@ export class TileLayer extends AbstractLayer {
|
|||
if (!this.isVisible() || !this.showAtZoomLevel(dataFilters.zoom)) {
|
||||
return;
|
||||
}
|
||||
const sourceDataRequest = this.getSourceDataRequest();
|
||||
if (sourceDataRequest) {//data is immmutable
|
||||
return;
|
||||
}
|
||||
const sourceDataId = 'source';
|
||||
const requestToken = Symbol(`layer-source-refresh:${ this.getId()} - source`);
|
||||
startLoading(sourceDataId, requestToken, dataFilters);
|
||||
|
@ -52,6 +56,12 @@ export class TileLayer extends AbstractLayer {
|
|||
|
||||
if (!source) {
|
||||
const sourceDataRequest = this.getSourceDataRequest();
|
||||
if (!sourceDataRequest) {
|
||||
//this is possible if the layer was invisible at startup.
|
||||
//the actions will not perform any data=syncing as an optimization when a layer is invisible
|
||||
//when turning the layer back into visible, it's possible the url has not been resovled yet.
|
||||
return;
|
||||
}
|
||||
const url = sourceDataRequest.getData();
|
||||
if (!url) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue