Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: environment and collection sync issue with firebase

Mohamed Yussuf10c568098ce2
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