aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/config.js3
-rw-r--r--src/modules/profileConfig.js (renamed from src/modules/serverSideConfig.js)22
2 files changed, 13 insertions, 12 deletions
diff --git a/src/modules/config.js b/src/modules/config.js
index 3d9cf591..6ab59d6d 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -1,6 +1,7 @@
import Cookies from 'js-cookie'
import { setPreset, applyTheme, applyConfig } from '../services/style_setter/style_setter.js'
import messages from '../i18n/messages'
+import { set } from 'lodash'
import localeService from '../services/locale/locale.service.js'
const BACKEND_LANGUAGE_COOKIE_NAME = 'userLanguage'
@@ -147,7 +148,7 @@ const config = {
},
mutations: {
setOption (state, { name, value }) {
- state[name] = value
+ set(state, name, value)
},
setHighlight (state, { user, color, type }) {
const data = this.state.config.highlight[user]
diff --git a/src/modules/serverSideConfig.js b/src/modules/profileConfig.js
index 476263bc..2cb2014a 100644
--- a/src/modules/serverSideConfig.js
+++ b/src/modules/profileConfig.js
@@ -22,9 +22,9 @@ const notificationsApi = ({ rootState, commit }, { path, value, oldValue }) => {
.updateNotificationSettings({ settings })
.then(result => {
if (result.status === 'success') {
- commit('confirmServerSideOption', { name, value })
+ commit('confirmProfileOption', { name, value })
} else {
- commit('confirmServerSideOption', { name, value: oldValue })
+ commit('confirmProfileOption', { name, value: oldValue })
}
})
}
@@ -94,16 +94,16 @@ export const settingsMap = {
export const defaultState = Object.fromEntries(Object.keys(settingsMap).map(key => [key, null]))
-const serverSideConfig = {
+const profileConfig = {
state: { ...defaultState },
mutations: {
- confirmServerSideOption (state, { name, value }) {
+ confirmProfileOption (state, { name, value }) {
set(state, name, value)
},
- wipeServerSideOption (state, { name }) {
+ wipeProfileOption (state, { name }) {
set(state, name, null)
},
- wipeAllServerSideOptions (state) {
+ wipeAllProfileOptions (state) {
Object.keys(settingsMap).forEach(key => {
set(state, key, null)
})
@@ -118,23 +118,23 @@ const serverSideConfig = {
}
},
actions: {
- setServerSideOption ({ rootState, state, commit, dispatch }, { name, value }) {
+ setProfileOption ({ rootState, state, commit, dispatch }, { name, value }) {
const oldValue = get(state, name)
const map = settingsMap[name]
if (!map) throw new Error('Invalid server-side setting')
const { set: path = map, api = defaultApi } = map
- commit('wipeServerSideOption', { name })
+ commit('wipeProfileOption', { name })
api({ rootState, commit }, { path, value, oldValue })
.catch((e) => {
console.warn('Error setting server-side option:', e)
- commit('confirmServerSideOption', { name, value: oldValue })
+ commit('confirmProfileOption', { name, value: oldValue })
})
},
logout ({ commit }) {
- commit('wipeAllServerSideOptions')
+ commit('wipeAllProfileOptions')
}
}
}
-export default serverSideConfig
+export default profileConfig