From 76f6f9d63937e029ad0a96c2c3ee61d88e3af396 Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Wed, 18 Nov 2020 23:17:59 +0000 Subject: [PATCH] Fix error when Nominatim region check was aborted. Also overcomes Leaflet 1.7.1 bug when Safari triggers double click event on map. Fixes #285 --- public/js/module/admin/regionCheck.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/public/js/module/admin/regionCheck.js b/public/js/module/admin/regionCheck.js index 9d21437fe..bc16bd996 100644 --- a/public/js/module/admin/regionCheck.js +++ b/public/js/module/admin/regionCheck.js @@ -187,17 +187,14 @@ define([ updateRegionAbort: function () { if (this.ownRegionsDeffered) { this.ownRegionsDeffered.reject(); - this.ownRegionsDeffered = null; } if (this.nominatimRegionsDeffered) { this.nominatimRegionsDeffered.reject(); - this.nominatimRegionsDeffered = null; } if (requestNominatim) { requestNominatim.abort(); - requestNominatim = null; } }, updateRegion: function (geo) { @@ -257,6 +254,7 @@ define([ '&accept-language=' + P.settings.lang, { crossDomain: true, + dataType: 'json', cache: false, context: this, @@ -264,7 +262,13 @@ define([ ); requestNominatim .fail(function (jqXHR, textStatus, errorThrown) { - if (jqXHR.responseJSON.hasOwnProperty('error')) { + if (textStatus === 'abort') { + // We must have clicked before previous request + // finished. + return; + } + + if (jqXHR.responseJSON && jqXHR.responseJSON.hasOwnProperty('error')) { tplObj.narr.push({ 'err': jqXHR.responseJSON.error.message }); console.warn('Error: ' + jqXHR.responseText); } else {