From 468c04d24a682a5e9b723134790f9fbc305331df Mon Sep 17 00:00:00 2001
From: Thomas Citharel <tcit@tcit.fr>
Date: Tue, 2 Mar 2021 10:02:06 +0100
Subject: [PATCH] Disable geolocation on prefered events area selection

Since we restrict to administrative areas and not full addresses

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
---
 js/src/components/Event/AddressAutoComplete.vue | 10 ++++++++--
 js/src/views/Settings/Preferences.vue           |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/js/src/components/Event/AddressAutoComplete.vue b/js/src/components/Event/AddressAutoComplete.vue
index f156469b5..407c991f7 100644
--- a/js/src/components/Event/AddressAutoComplete.vue
+++ b/js/src/components/Event/AddressAutoComplete.vue
@@ -20,7 +20,7 @@
         </template>
       </b-autocomplete>
     </b-field>
-    <b-field v-if="isSecureContext()">
+    <b-field v-if="canDoGeoLocation">
       <b-button
         type="is-text"
         v-if="!gettingLocation"
@@ -72,6 +72,8 @@ import { IConfig } from "../../types/config.model";
 export default class AddressAutoComplete extends Vue {
   @Prop({ required: true }) value!: IAddress;
   @Prop({ required: false, default: false }) type!: string | false;
+  @Prop({ required: false, default: true, type: Boolean })
+  doGeoLocation!: boolean;
 
   addressData: IAddress[] = [];
 
@@ -244,9 +246,13 @@ export default class AddressAutoComplete extends Vue {
   }
 
   // eslint-disable-next-line class-methods-use-this
-  isSecureContext(): boolean {
+  get isSecureContext(): boolean {
     return window.isSecureContext;
   }
+
+  get canDoGeoLocation(): boolean {
+    return this.isSecureContext && this.doGeoLocation;
+  }
 }
 </script>
 <style lang="scss">
diff --git a/js/src/views/Settings/Preferences.vue b/js/src/views/Settings/Preferences.vue
index 4cc9ff690..1725a13e6 100644
--- a/js/src/views/Settings/Preferences.vue
+++ b/js/src/views/Settings/Preferences.vue
@@ -63,6 +63,7 @@
               loggedUser && loggedUser.settings && loggedUser.settings.location
             "
             :type="AddressSearchType.ADMINISTRATIVE"
+            :doGeoLocation="false"
             v-model="address"
           >
           </address-auto-complete>