Language now managed in VueX store

This commit is contained in:
Alicia Sykes
2021-10-10 15:52:39 +01:00
parent 048f0cb112
commit 4e3b41332d
4 changed files with 28 additions and 6 deletions

View File

@@ -8,11 +8,12 @@ import filterUserSections from '@/utils/CheckSectionVisibility';
Vue.use(Vuex);
const { UPDATE_CONFIG, SET_MODAL_OPEN } = Keys;
const { UPDATE_CONFIG, SET_MODAL_OPEN, SET_LANGUAGE } = Keys;
const store = new Vuex.Store({
state: {
config: {},
lang: '', // The users language, auto-detected or read from local storage / config
modalOpen: false, // KB shortcut functionality will be disabled when modal is open
},
getters: {
@@ -39,11 +40,15 @@ const store = new Vuex.Store({
[UPDATE_CONFIG](state, config) {
state.config = config;
},
[SET_LANGUAGE](state, lang) {
state.lang = lang;
},
[SET_MODAL_OPEN](state, modalOpen) {
state.modalOpen = modalOpen;
},
},
actions: {
/* Called when app first loaded. Reads config and sets state */
initializeConfig({ commit }) {
const Accumulator = new ConfigAccumulator();
const config = Accumulator.config();