Save Collections/Environments on enabling sync

This commit is contained in:
Samir L. Boulema
2020-05-08 16:13:41 +02:00
parent 7e3c775f70
commit d60939211a

View File

@@ -372,8 +372,14 @@ export default {
this.settings[key] = !this.settings[key] this.settings[key] = !this.settings[key]
this.$store.commit("postwoman/applySetting", [key, this.settings[key]]) this.$store.commit("postwoman/applySetting", [key, this.settings[key]])
}, },
toggleSettings(s, v) { toggleSettings(name, value) {
fb.writeSettings(s, !v) fb.writeSettings(name, !value)
if (name === "syncCollections" && value) {
syncCollections()
}
if (name === "syncEnvironments" && value) {
syncEnvironments()
}
}, },
initSettings() { initSettings() {
fb.writeSettings("syncHistory", true) fb.writeSettings("syncHistory", true)
@@ -388,6 +394,20 @@ export default {
}) })
setTimeout(() => (target.innerHTML = '<i class="material-icons">clear_all</i>'), 1000) 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() { beforeMount() {