Skip to content

Commit

Permalink
fix(maintenance): add init entry to init store only one time (#1914)
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Dej <meteyou@gmail.com>
  • Loading branch information
meteyou authored Jun 24, 2024
1 parent 57423d4 commit 446ff5c
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 446ff5c

Please sign in to comment.