Mercurial > gemma
changeset 1438:71eb96690f91
avoid unnecessary setSelectedBottleneck call
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Fri, 30 Nov 2018 11:12:47 +0100 |
parents | 1cd1549aab47 |
children | 910d08ba6305 b3920ac3b2fd a4554e942954 |
files | client/src/store/map.js |
diffstat | 1 files changed, 22 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/store/map.js Fri Nov 30 10:42:00 2018 +0100 +++ b/client/src/store/map.js Fri Nov 30 11:12:47 2018 +0100 @@ -488,7 +488,7 @@ unByKey(state.identifyTool); state.identifyTool = null; }, - enableIdentifyTool({ state, commit, dispatch, getters }) { + enableIdentifyTool({ state, rootState, commit, dispatch, getters }) { if (!state.identifyTool) { state.identifyTool = state.openLayersMap.on( ["singleclick", "dblclick"], @@ -504,22 +504,27 @@ let id = feature.getId(); // RegExp.prototype.test() works with number, str and undefined if (/^bottlenecks\./.test(id)) { - dispatch( - "bottlenecks/setSelectedBottleneck", - feature.get("objnam"), - { root: true } - ); - commit("moveMap", { - coordinates: getCenter( - feature - .getGeometry() - .clone() - .transform("EPSG:3857", "EPSG:4326") - .getExtent() - ), - zoom: 17, - preventZoomOut: true - }); + if ( + rootState.bottlenecks.selectedBottleneck != + feature.get("objnam") + ) { + dispatch( + "bottlenecks/setSelectedBottleneck", + feature.get("objnam"), + { root: true } + ); + commit("moveMap", { + coordinates: getCenter( + feature + .getGeometry() + .clone() + .transform("EPSG:3857", "EPSG:4326") + .getExtent() + ), + zoom: 17, + preventZoomOut: true + }); + } } } }