Ensure any existing layers get cleared when previewing a new one (#31973)

This commit is contained in:
Thomas Neirynck 2019-02-25 23:05:15 -05:00 committed by GitHub
parent a037874e4a
commit 79a26aef36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,7 +33,12 @@ function mapDispatchToProps(dispatch) {
closeFlyout: () => {
dispatch(clearTransientLayerStateAndCloseFlyout());
},
previewLayer: layer => {
previewLayer: async (layer) => {
//this removal always needs to happen prior to adding the new layer
//many source editors allow users to modify the settings in the add-source wizard
//this triggers a new request for preview. Any existing transient layers need to be cleared before the new one can be added.
await dispatch(setSelectedLayer(null));
await dispatch(removeTransientLayer());
dispatch(addLayer(layer.toLayerDescriptor()));
dispatch(setSelectedLayer(layer.getId()));
dispatch(setTransientLayer(layer.getId()));