From c6934d751fc8d60e18b9a0a1209430c66af886c0 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Sun, 7 Nov 2021 16:06:28 +0100 Subject: [PATCH] refactor: new order of init moonraker databases and printer Signed-off-by: Stefan Dej --- src/store/gui/actions.ts | 8 +++++--- src/store/server/actions.ts | 10 +++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/store/gui/actions.ts b/src/store/gui/actions.ts index 6b90275f..aaa6b94f 100644 --- a/src/store/gui/actions.ts +++ b/src/store/gui/actions.ts @@ -10,8 +10,12 @@ export const actions: ActionTree = { commit('reset') }, - init({ commit, dispatch, rootState }, payload) { + init() { window.console.debug('init gui') + Vue.$socket.emit('server.database.get_item', { namespace: 'mainsail' }, { action: 'gui/initStore'}) + }, + + initStore({ commit, dispatch, rootState }, payload) { //added in V2.1 if ( @@ -67,8 +71,6 @@ export const actions: ActionTree = { // init remote printers, when remoteMode is off if (!rootState.socket?.remoteMode) dispatch('farm/readStoredPrinters', {}, { root: true }) - - dispatch('printer/init', null, { root: true }) }, saveSetting({ commit }, payload) { diff --git a/src/store/server/actions.ts b/src/store/server/actions.ts index 7a8447ec..905666d2 100644 --- a/src/store/server/actions.ts +++ b/src/store/server/actions.ts @@ -23,15 +23,11 @@ export const actions: ActionTree = { }, checkDatabases({ dispatch }, payload) { - if (payload.namespaces?.includes('mainsail')) - Vue.$socket.emit('server.database.get_item', { namespace: 'mainsail' }, { action: 'gui/init'}) - else { - Vue.$socket.emit('server.database.post_item', { namespace: 'mainsail', key: 'init', value: true }) - dispatch('printer/init', null, { root: true }) - } - + if (payload.namespaces?.includes('mainsail')) dispatch('gui/init', null, { root: true }) if (payload.namespaces?.includes('webcams')) dispatch('gui/webcams/init', null, { root: true }) if (payload.namespaces?.includes('mainsail_presets')) dispatch('gui/presets/init', null, { root: true }) + + dispatch('printer/init', null, { root: true }) }, initServerInfo: function ({ dispatch, commit }, payload) {