From c6833169dd4e961111a735a337c9991ad9b8364c Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 27 Oct 2022 04:21:48 +0400 Subject: [PATCH] fix double geolocation.getCurrentPosition() call (incorrect behavior in the Firefox - function called once) --- src/components/poll/FeltReportPoll.vue | 9 +++- src/components/poll/LocationQuestions.vue | 46 +++++++++++-------- .../mixins/{geolocation.js => timezone.js} | 30 ------------ 3 files changed, 34 insertions(+), 51 deletions(-) rename src/components/poll/mixins/{geolocation.js => timezone.js} (53%) diff --git a/src/components/poll/FeltReportPoll.vue b/src/components/poll/FeltReportPoll.vue index f51b067..6132fb0 100644 --- a/src/components/poll/FeltReportPoll.vue +++ b/src/components/poll/FeltReportPoll.vue @@ -60,16 +60,20 @@ diff --git a/src/components/poll/mixins/geolocation.js b/src/components/poll/mixins/timezone.js similarity index 53% rename from src/components/poll/mixins/geolocation.js rename to src/components/poll/mixins/timezone.js index bdc9010..21984f6 100644 --- a/src/components/poll/mixins/geolocation.js +++ b/src/components/poll/mixins/timezone.js @@ -3,10 +3,6 @@ import ts from '@mapbox/timespace' export default { data() { return { - location: { - lat: null, - lon: null - }, timezoneOffset: 0, timezone: 'UTC' } @@ -29,32 +25,6 @@ export default { const time = ts.getFuzzyLocalTimeFromPoint(timestamp, point) this.timezoneOffset = time._d.getTimezoneOffset() this.timezone = this.formatTimezone(this.timezoneOffset) - }, - getCurrentLocation() { - let vm = this - window.navigator.geolocation.getCurrentPosition( - function(position) { - vm.location.lat = position.coords.latitude - vm.location.lon = position.coords.longitude - vm.getTimezone() - }, - function(error) { - const errorTypes = { - 1: 'PERMISSION_DENIED', - 2: 'POSITION_UNAVAILABLE', - 3: 'TIMEOUT' - } - console.error(error.message, {code: errorTypes[error.code]}) - } - ) - } - }, - mounted() { - if (window.navigator.geolocation) { - this.getCurrentLocation() - } - else { - console.warn('GeoLocation API is unavailable for your browser') } } }