Skip to content

Commit

Permalink
fix(maintenance): add init store entry to init maintenance store only…
Browse files Browse the repository at this point in the history
… one time

Signed-off-by: Stefan Dej <meteyou@gmail.com>
  • Loading branch information
meteyou committed Jun 16, 2024
1 parent b5599ef commit 78fac5f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/store/gui/maintenance/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export const actions: ActionTree<GuiMaintenanceState, RootState> = {
// stop, when no entries are available/found
const entries = defaults.entries ?? []
if (entries?.length === 0) {
Vue.$socket.emit('server.database.post_item', {
namespace: 'maintenance',
key: uuidv4(),
value: {
name: 'MAINTENANCE_INIT',
},
})

return
}

Expand Down Expand Up @@ -92,7 +100,12 @@ export const actions: ActionTree<GuiMaintenanceState, RootState> = {

async initStore({ commit, dispatch }, payload) {
await commit('reset')
await commit('initStore', payload)

const entries = payload.value ?? {}
const initKey = Object.keys(entries).find((key) => entries[key]?.name === 'MAINTENANCE_INIT')
if (initKey) delete entries[initKey]

await commit('initStore', entries)
await dispatch('socket/removeInitModule', 'gui/maintenance/init', { root: true })
},

Expand Down
2 changes: 1 addition & 1 deletion src/store/gui/maintenance/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const mutations: MutationTree<GuiMaintenanceState> = {
},

initStore(state, payload) {
Vue.set(state, 'entries', payload.value)
Vue.set(state, 'entries', payload)
},

store(state, payload) {
Expand Down

0 comments on commit 78fac5f

Please sign in to comment.