Skip to content
Snippets Groups Projects
Commit 189863fd authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

fix: postpone handling of location changed until async function is done

parent fc4fb61a
No related branches found
No related tags found
1 merge request!191Add map module and Open-Meteo support
...@@ -174,14 +174,15 @@ ...@@ -174,14 +174,15 @@
function callbackOnCloseLocationMap(poiData) { function callbackOnCloseLocationMap(poiData) {
if(!poiData.pointOfInterestId) { if(!poiData.pointOfInterestId) {
persistNewLocation(poiData); persistNewLocation(poiData, handleLocationChanged);
} else { } else {
selectPoi(selectLocationElement, poiData.pointOfInterestId); selectPoi(selectLocationElement, poiData.pointOfInterestId);
handleLocationChanged();
} }
handleLocationChanged();
} }
function persistNewLocation(poiData) { function persistNewLocation(poiData, callback) {
fetch("/rest/poi", { fetch("/rest/poi", {
method: 'POST', method: 'POST',
headers: { headers: {
...@@ -197,7 +198,8 @@ ...@@ -197,7 +198,8 @@
renderPoiSelect(selectLocationElement, locationList, poi.pointOfInterestId); renderPoiSelect(selectLocationElement, locationList, poi.pointOfInterestId);
// Assuming that this is not a weather station, since weather stations cannot be created using the // Assuming that this is not a weather station, since weather stations cannot be created using the
// map, the user must have created a .... MAYBE HANDLED AUTOMATICALLY?? by the change event?? // map, the user must have created a .... MAYBE HANDLED AUTOMATICALLY?? by the change event??
console.info("Point of interest successfully persisted", poi); //console.info("Point of interest successfully persisted", poi);
callback();
}) })
.catch(error => { .catch(error => {
console.error("Unable to persist new point of interest", error); console.error("Unable to persist new point of interest", error);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment