From 51b67d46a09b4d054570e45773b18edf5259a37f Mon Sep 17 00:00:00 2001 From: Marco Endrizzi <me00531@surrey.ac.uk> Date: Fri, 23 Apr 2021 07:39:13 -0700 Subject: [PATCH] Fixed a bug where userPosition was not saved in db --- src/App.vue | 2 +- src/components/GoogleMap.vue | 5 ++++- src/store/firebase.js | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/App.vue b/src/App.vue index 72dc531..973b223 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,7 +13,7 @@ export default defineComponent({ ...mapActions('firebase', ['handleAuthStateChanged']) }, - mounted() { + created() { this.handleAuthStateChanged() } }) diff --git a/src/components/GoogleMap.vue b/src/components/GoogleMap.vue index 88f47c1..25f4e00 100644 --- a/src/components/GoogleMap.vue +++ b/src/components/GoogleMap.vue @@ -15,7 +15,7 @@ q-btn( color='grey-10', icon='my_location', style='position: absolute; right: 1.25em; bottom: 2.5em; z-index: 1' -) +) </template> <script> @@ -247,6 +247,9 @@ export default { for (const userId in this.users) { this.mapsAddUserMarker(userId) } + + // Reinitialize user on the map + this.geolocate() }, /* Creates markers and infoWindows for every relevant nightlife establishment in the area */ diff --git a/src/store/firebase.js b/src/store/firebase.js index 0e24e92..1cfb9d1 100644 --- a/src/store/firebase.js +++ b/src/store/firebase.js @@ -384,7 +384,10 @@ const actions = { firebaseSavePosition({ state, commit }, payload) { let center = payload // Update position in the db - firebaseDb.ref('status/' + state.userDetails.userId).update({position: center}) + if (state.userDetails.userId) { + firebaseDb.ref('status/' + state.userDetails.userId).update({position: center}) + } + // Update position in the store commit('setUserCenter', center) }, -- GitLab