From 10c568098ce22517d000b9b03d52dd59555d3090 Mon Sep 17 00:00:00 2001 From: Mohamed Yussuf Date: Mon, 8 Jun 2020 00:44:22 +0800 Subject: [PATCH 1/3] 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 From 0bf2ba541602b78aa92705d5c51a896245a5f29a Mon Sep 17 00:00:00 2001 From: Mohamed Yussuf Date: Mon, 8 Jun 2020 01:32:14 +0800 Subject: [PATCH 2/3] fix: not login issue --- components/collections/index.vue | 3 ++- components/environments/index.vue | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/collections/index.vue b/components/collections/index.vue index 890510b50..77db8ad86 100644 --- a/components/collections/index.vue +++ b/components/collections/index.vue @@ -134,7 +134,8 @@ export default { }, computed: { collections() { - return fb.currentCollections; + return fb.currentUser !== null + ? fb.currentCollections : this.$store.state.postwoman.collections }, }, async mounted() { diff --git a/components/environments/index.vue b/components/environments/index.vue index 12e39397a..e3f3af215 100644 --- a/components/environments/index.vue +++ b/components/environments/index.vue @@ -82,7 +82,8 @@ export default { }, computed: { environments() { - return fb.currentEnvironments; + return fb.currentUser !== null + ? fb.currentEnvironments : this.$store.state.postwoman.environments }, }, async mounted() { From f477998b2fb9edf1c81109bfac92e35b22f66117 Mon Sep 17 00:00:00 2001 From: Mohamed Yussuf Date: Mon, 8 Jun 2020 01:56:13 +0800 Subject: [PATCH 3/3] fix: add sync firebase for all the commit --- components/collections/addCollection.vue | 1 + components/collections/collection.vue | 10 ++++++++++ components/collections/editCollection.vue | 12 +++++++++++- components/collections/editFolder.vue | 10 ++++++++++ components/collections/editRequest.vue | 10 ++++++++++ components/collections/folder.vue | 10 ++++++++++ components/collections/request.vue | 10 ++++++++++ components/environments/editEnvironment.vue | 11 +++++++++++ components/environments/environment.vue | 10 ++++++++++ 9 files changed, 83 insertions(+), 1 deletion(-) diff --git a/components/collections/addCollection.vue b/components/collections/addCollection.vue index 518db55d4..e00dec3c3 100644 --- a/components/collections/addCollection.vue +++ b/components/collections/addCollection.vue @@ -78,6 +78,7 @@ export default { }, hideModal() { this.$emit("hide-modal") + this.$data.name = undefined }, }, } diff --git a/components/collections/collection.vue b/components/collections/collection.vue index f4d52df49..c59209826 100644 --- a/components/collections/collection.vue +++ b/components/collections/collection.vue @@ -87,6 +87,8 @@ ul li {