From 10c568098ce22517d000b9b03d52dd59555d3090 Mon Sep 17 00:00:00 2001 From: Mohamed Yussuf Date: Mon, 8 Jun 2020 00:44:22 +0800 Subject: [PATCH] fix: environment and collection sync issue with firebase --- components/collections/index.vue | 2 +- components/environments/index.vue | 2 +- functions/fb.js | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/collections/index.vue b/components/collections/index.vue index f5fed9681..890510b50 100644 --- a/components/collections/index.vue +++ b/components/collections/index.vue @@ -134,7 +134,7 @@ export default { }, computed: { collections() { - return this.$store.state.postwoman.collections + return fb.currentCollections; }, }, async mounted() { diff --git a/components/environments/index.vue b/components/environments/index.vue index 60b8b3cef..12e39397a 100644 --- a/components/environments/index.vue +++ b/components/environments/index.vue @@ -82,7 +82,7 @@ export default { }, computed: { environments() { - return this.$store.state.postwoman.environments + return fb.currentEnvironments; }, }, async mounted() { diff --git a/functions/fb.js b/functions/fb.js index 9da0f49ae..0b13ae306 100644 --- a/functions/fb.js +++ b/functions/fb.js @@ -200,7 +200,9 @@ firebase.auth().onAuthStateChanged((user) => { collection.id = doc.id collections.push(collection) }) - fb.currentCollections = collections[0].collection + if (collections.length > 0) { + fb.currentCollections = collections[0].collection + } }) usersCollection @@ -213,7 +215,9 @@ firebase.auth().onAuthStateChanged((user) => { environment.id = doc.id environments.push(environment) }) - fb.currentEnvironments = environments[0].environment + if (environments.length > 0) { + fb.currentEnvironments = environments[0].environment + } }) } else { fb.currentUser = null