From cd3a3047440777967688d7fd3f537acad7fd78e5 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Sat, 13 Nov 2021 20:30:55 +0000 Subject: [PATCH] :construction: Started working on itnitial state for widgets --- src/store.js | 9 ++++++--- src/utils/ConfigAccumalator.js | 11 +++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/store.js b/src/store.js index 7f9aaaf9..2df242ec 100644 --- a/src/store.js +++ b/src/store.js @@ -51,12 +51,15 @@ const store = new Vuex.Store({ appConfig(state) { return state.config.appConfig || {}; }, - theme(state) { - return state.config.appConfig.theme; - }, sections(state) { return filterUserSections(state.config.sections || []); }, + widgets(state) { + return state.config.widgets || []; + }, + theme(state) { + return state.config.appConfig.theme; + }, webSearch(state, getters) { return getters.appConfig.webSearch || {}; }, diff --git a/src/utils/ConfigAccumalator.js b/src/utils/ConfigAccumalator.js index 041306e9..018c4f25 100644 --- a/src/utils/ConfigAccumalator.js +++ b/src/utils/ConfigAccumalator.js @@ -78,12 +78,23 @@ export default class ConfigAccumulator { return sections; } + /* Widgets */ + widgets() { + const localWidgets = localStorage[localStorageKeys.CONF_WIDGETS]; + if (localWidgets) { + const json = JSON.parse(localWidgets); + if (json.length >= 1) return json; + } + return this.conf.widgets || []; + } + /* Complete config */ config() { return { appConfig: this.appConfig(), pageInfo: this.pageInfo(), sections: this.sections(), + widgets: this.widgets(), }; } }