Skip to content

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

Save Collections/Environments on enabling sync

Samir L. Boulemad60939211a09
diff --git a/pages/settings.vue b/pages/settings.vue
index f48d32a8f..6feba75c6 100644
--- a/pages/settings.vue
+++ b/pages/settings.vue
@@ -372,8 +372,14 @@ export default {
this.settings[key] = !this.settings[key]
this.$store.commit("postwoman/applySetting", [key, this.settings[key]])
},
- toggleSettings(s, v) {
- fb.writeSettings(s, !v)
+ toggleSettings(name, value) {
+ fb.writeSettings(name, !value)
+ if (name === "syncCollections" && value) {
+ syncCollections()
+ }
+ if (name === "syncEnvironments" && value) {
+ syncEnvironments()
+ }
},
initSettings() {
fb.writeSettings("syncHistory", true)
@@ -388,6 +394,20 @@ export default {
})
setTimeout(() => (target.innerHTML = '<i class="material-icons">clear_all</i>'), 1000)
},
+ syncCollections() {
+ if (fb.currentUser !== null) {
+ if (fb.currentSettings[0].value) {
+ fb.writeCollections(JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)))
+ }
+ }
+ },
+ syncEnvironments() {
+ if (fb.currentUser !== null) {
+ if (fb.currentSettings[1].value) {
+ fb.writeEnvironments(JSON.parse(JSON.stringify(this.$store.state.postwoman.environments)))
+ }
+ }
+ },
},
beforeMount() {