Merge pull request #926 from myussufz/hotfix/sync-collections-and-environment

This commit is contained in:
Liyas Thomas
2020-06-08 10:49:13 +05:30
committed by GitHub
12 changed files with 93 additions and 5 deletions

View File

@@ -78,6 +78,7 @@ export default {
}, },
hideModal() { hideModal() {
this.$emit("hide-modal") this.$emit("hide-modal")
this.$data.name = undefined
}, },
}, },
} }

View File

@@ -87,6 +87,8 @@ ul li {
</style> </style>
<script> <script>
import { fb } from "../../functions/fb"
export default { export default {
components: { components: {
folder: () => import("./folder"), folder: () => import("./folder"),
@@ -103,6 +105,13 @@ export default {
} }
}, },
methods: { methods: {
syncCollections() {
if (fb.currentUser !== null) {
if (fb.currentSettings[0].value) {
fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
}
}
},
toggleShowChildren() { toggleShowChildren() {
this.showChildren = !this.showChildren this.showChildren = !this.showChildren
}, },
@@ -111,6 +120,7 @@ export default {
this.$store.commit("postwoman/removeCollection", { this.$store.commit("postwoman/removeCollection", {
collectionIndex: this.collectionIndex, collectionIndex: this.collectionIndex,
}) })
this.syncCollections();
}, },
editFolder(collectionIndex, folder, folderIndex) { editFolder(collectionIndex, folder, folderIndex) {
this.$emit("edit-folder", { collectionIndex, folder, folderIndex }) this.$emit("edit-folder", { collectionIndex, folder, folderIndex })

View File

@@ -43,6 +43,8 @@
</template> </template>
<script> <script>
import { fb } from "../../functions/fb"
export default { export default {
props: { props: {
show: Boolean, show: Boolean,
@@ -58,6 +60,13 @@ export default {
} }
}, },
methods: { methods: {
syncCollections() {
if (fb.currentUser !== null) {
if (fb.currentSettings[0].value) {
fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
}
}
},
saveCollection() { saveCollection() {
if (!this.$data.name) { if (!this.$data.name) {
this.$toast.info(this.$t("invalid_collection_name")) this.$toast.info(this.$t("invalid_collection_name"))
@@ -71,7 +80,8 @@ export default {
collection: collectionUpdated, collection: collectionUpdated,
collectionIndex: this.$props.editingCollectionIndex, collectionIndex: this.$props.editingCollectionIndex,
}) })
this.$emit("hide-modal") this.$emit("hide-modal");
this.syncCollections();
}, },
hideModal() { hideModal() {
this.$emit("hide-modal") this.$emit("hide-modal")

View File

@@ -38,6 +38,8 @@
</template> </template>
<script> <script>
import { fb } from "../../functions/fb"
export default { export default {
props: { props: {
show: Boolean, show: Boolean,
@@ -55,6 +57,13 @@ export default {
} }
}, },
methods: { methods: {
syncCollections() {
if (fb.currentUser !== null) {
if (fb.currentSettings[0].value) {
fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
}
}
},
editFolder() { editFolder() {
this.$store.commit("postwoman/editFolder", { this.$store.commit("postwoman/editFolder", {
collectionIndex: this.$props.collectionIndex, collectionIndex: this.$props.collectionIndex,
@@ -62,6 +71,7 @@ export default {
folderIndex: this.$props.folderIndex, folderIndex: this.$props.folderIndex,
}) })
this.hideModal() this.hideModal()
this.syncCollections();
}, },
hideModal() { hideModal() {
this.$emit("hide-modal") this.$emit("hide-modal")

View File

@@ -69,6 +69,8 @@
</template> </template>
<script> <script>
import { fb } from "../../functions/fb"
export default { export default {
props: { props: {
show: Boolean, show: Boolean,
@@ -106,6 +108,13 @@ export default {
}, },
}, },
methods: { methods: {
syncCollections() {
if (fb.currentUser !== null) {
if (fb.currentSettings[0].value) {
fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
}
}
},
saveRequest() { saveRequest() {
const userSelectedAnyCollection = this.$data.requestUpdateData.collectionIndex !== undefined const userSelectedAnyCollection = this.$data.requestUpdateData.collectionIndex !== undefined
@@ -130,6 +139,7 @@ export default {
}) })
this.hideModal() this.hideModal()
this.syncCollections();
}, },
hideModal() { hideModal() {
this.$emit("hide-modal") this.$emit("hide-modal")

View File

@@ -70,6 +70,8 @@ ul li {
</style> </style>
<script> <script>
import { fb } from "../../functions/fb"
export default { export default {
props: { props: {
folder: Object, folder: Object,
@@ -85,6 +87,13 @@ export default {
} }
}, },
methods: { methods: {
syncCollections() {
if (fb.currentUser !== null) {
if (fb.currentSettings[0].value) {
fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
}
}
},
toggleShowChildren() { toggleShowChildren() {
this.showChildren = !this.showChildren this.showChildren = !this.showChildren
}, },
@@ -97,6 +106,7 @@ export default {
collectionIndex: this.collectionIndex, collectionIndex: this.collectionIndex,
folderIndex: this.folderIndex, folderIndex: this.folderIndex,
}) })
this.syncCollections();
}, },
editFolder() { editFolder() {
this.$emit("edit-folder") this.$emit("edit-folder")

View File

@@ -134,7 +134,8 @@ export default {
}, },
computed: { computed: {
collections() { collections() {
return this.$store.state.postwoman.collections return fb.currentUser !== null
? fb.currentCollections : this.$store.state.postwoman.collections
}, },
}, },
async mounted() { async mounted() {

View File

@@ -42,6 +42,8 @@ ul li {
</style> </style>
<script> <script>
import { fb } from "../../functions/fb"
export default { export default {
props: { props: {
request: Object, request: Object,
@@ -50,6 +52,13 @@ export default {
requestIndex: Number, requestIndex: Number,
}, },
methods: { methods: {
syncCollections() {
if (fb.currentUser !== null) {
if (fb.currentSettings[0].value) {
fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
}
}
},
selectRequest() { selectRequest() {
this.$store.commit("postwoman/selectRequest", { request: this.request }) this.$store.commit("postwoman/selectRequest", { request: this.request })
}, },
@@ -60,6 +69,7 @@ export default {
folderIndex: this.folderIndex, folderIndex: this.folderIndex,
requestIndex: this.requestIndex, requestIndex: this.requestIndex,
}) })
this.syncCollections();
}, },
}, },
} }

View File

@@ -115,6 +115,7 @@
<script> <script>
import textareaAutoHeight from "../../directives/textareaAutoHeight" import textareaAutoHeight from "../../directives/textareaAutoHeight"
import { fb } from "../../functions/fb"
export default { export default {
directives: { directives: {
@@ -152,6 +153,13 @@ export default {
}, },
}, },
methods: { methods: {
syncEnvironments() {
if (fb.currentUser !== null) {
if (fb.currentSettings[1].value) {
fb.writeEnvironments(JSON.parse(JSON.stringify(this.$store.state.postwoman.environments)))
}
}
},
clearContent(e) { clearContent(e) {
this.$store.commit("postwoman/removeVariables", []) this.$store.commit("postwoman/removeVariables", [])
e.target.innerHTML = this.doneButton e.target.innerHTML = this.doneButton
@@ -163,6 +171,7 @@ export default {
addEnvironmentVariable() { addEnvironmentVariable() {
let value = { key: "", value: "" } let value = { key: "", value: "" }
this.$store.commit("postwoman/addVariable", value) this.$store.commit("postwoman/addVariable", value)
this.syncEnvironments()
}, },
removeEnvironmentVariable(index) { removeEnvironmentVariable(index) {
let variableIndex = index let variableIndex = index
@@ -182,6 +191,7 @@ export default {
}, },
}, },
}) })
this.syncEnvironments()
}, },
saveEnvironment() { saveEnvironment() {
if (!this.$data.name) { if (!this.$data.name) {
@@ -197,6 +207,7 @@ export default {
environmentIndex: this.$props.editingEnvironmentIndex, environmentIndex: this.$props.editingEnvironmentIndex,
}) })
this.$emit("hide-modal") this.$emit("hide-modal")
this.syncEnvironments()
}, },
hideModal() { hideModal() {
this.$data.name = undefined this.$data.name = undefined

View File

@@ -42,15 +42,25 @@ ul li {
</style> </style>
<script> <script>
import { fb } from "../../functions/fb"
export default { export default {
props: { props: {
environment: Object, environment: Object,
environmentIndex: Number, environmentIndex: Number,
}, },
methods: { methods: {
syncEnvironments() {
if (fb.currentUser !== null) {
if (fb.currentSettings[1].value) {
fb.writeEnvironments(JSON.parse(JSON.stringify(this.$store.state.postwoman.environments)))
}
}
},
removeEnvironment() { removeEnvironment() {
if (!confirm("Are you sure you want to remove this environment?")) return if (!confirm("Are you sure you want to remove this environment?")) return
this.$store.commit("postwoman/removeEnvironment", this.environmentIndex) this.$store.commit("postwoman/removeEnvironment", this.environmentIndex)
this.syncEnvironments()
}, },
}, },
} }

View File

@@ -82,7 +82,8 @@ export default {
}, },
computed: { computed: {
environments() { environments() {
return this.$store.state.postwoman.environments return fb.currentUser !== null
? fb.currentEnvironments : this.$store.state.postwoman.environments
}, },
}, },
async mounted() { async mounted() {

View File

@@ -200,7 +200,9 @@ firebase.auth().onAuthStateChanged((user) => {
collection.id = doc.id collection.id = doc.id
collections.push(collection) collections.push(collection)
}) })
fb.currentCollections = collections[0].collection if (collections.length > 0) {
fb.currentCollections = collections[0].collection
}
}) })
usersCollection usersCollection
@@ -213,7 +215,9 @@ firebase.auth().onAuthStateChanged((user) => {
environment.id = doc.id environment.id = doc.id
environments.push(environment) environments.push(environment)
}) })
fb.currentEnvironments = environments[0].environment if (environments.length > 0) {
fb.currentEnvironments = environments[0].environment
}
}) })
} else { } else {
fb.currentUser = null fb.currentUser = null