Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

:nut_and_bolt: Adds updateSection functionality to store

Alicia Sykes0a00c9beb2a7
diff --git a/src/store.js b/src/store.js
index c99d9da9..c9cc1414 100644
--- a/src/store.js
+++ b/src/store.js
@@ -17,6 +17,7 @@ const {
SET_EDIT_MODE,
UPDATE_PAGE_INFO,
UPDATE_APP_CONFIG,
+ UPDATE_SECTION,
} = Keys;
const store = new Vuex.Store({
@@ -44,6 +45,10 @@ const store = new Vuex.Store({
visibleComponents(state, getters) {
return componentVisibility(getters.appConfig);
},
+ // eslint-disable-next-line arrow-body-style
+ getSectionByIndex: (state, getters) => (index) => {
+ return getters.sections[index];
+ },
getItemById: (state, getters) => (id) => {
let item;
getters.sections.forEach(sec => {
@@ -90,6 +95,12 @@ const store = new Vuex.Store({
newConfig.appConfig = newAppConfig;
state.config = newConfig;
},
+ [UPDATE_SECTION](state, payload) {
+ const { sectionIndex, sectionData } = payload;
+ const newConfig = { ...state.config };
+ newConfig.sections[sectionIndex] = sectionData;
+ state.config = newConfig;
+ },
},
actions: {
/* Called when app first loaded. Reads config and sets state */
diff --git a/src/utils/StoreMutations.js b/src/utils/StoreMutations.js
index 9cb70861..ba3cb51f 100644
--- a/src/utils/StoreMutations.js
+++ b/src/utils/StoreMutations.js
@@ -8,6 +8,7 @@ const KEY_NAMES = [
'UPDATE_ITEM',
'UPDATE_PAGE_INFO',
'UPDATE_APP_CONFIG',
+ 'UPDATE_SECTION',
];
// Convert array of key names into an object, and export