From b14ba38f4851d67dc1cba08a3537d725b15bd064 Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Wed, 24 Nov 2021 16:04:04 +0100 Subject: [PATCH] refactor toggle --- src/components/Menu.vue | 6 +++--- src/main.js | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/Menu.vue b/src/components/Menu.vue index 2f3e68ae..36c4e1ad 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -70,17 +70,17 @@ export default { computed: { toggleSearchToolbar: { get () { return this.$store.state.showSearchToolbar}, - set () { this.$store.commit("toggleSearchToolbar") + set () { this.$store.commit("toggle", "showSearchToolbar") } }, toggleHGNO: { get () { return this.$store.state.showHGNO}, - set () { this.$store.commit("toggleHGNO") + set () { this.$store.commit("toggle", "showHGNO") } }, toggleInflectionNo: { get () { return this.$store.state.showInflectionNo}, - set () { this.$store.commit("toggleInflectionNo") + set () { this.$store.commit("toggle", "showInflectionNo") } }, diff --git a/src/main.js b/src/main.js index 613b04c5..f791ea85 100644 --- a/src/main.js +++ b/src/main.js @@ -42,12 +42,12 @@ const store = new Vuex.Store({ }, changeLocale(state, locale) { state.currentLocale = locale - localStorage.setItem("showSearchToolbar", locale); + localStorage.setItem("currentLocale", locale); }, - toggleSearchToolbar(state) { - let value = !state.showSearchToolbar - state.showSearchToolbar = value - localStorage.setItem("showSearchToolbar", value); + toggle(state, setting) { + let value = !state[setting] + state[setting] = value + localStorage.setItem(setting, value); } } }) -- GitLab