From d60939211a0995d3f408a5ae9b26a7e937fb75c1 Mon Sep 17 00:00:00 2001 From: "Samir L. Boulema" Date: Fri, 8 May 2020 16:13:41 +0200 Subject: [PATCH] Save Collections/Environments on enabling sync --- pages/settings.vue | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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 = 'clear_all'), 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() {