From 0befcea6589737e9904bc4128f73ce6c464cffd2 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 12 Jan 2021 23:02:33 +0100 Subject: [PATCH] bugfix: clear new printer objects on reset Signed-off-by: Stefan Dej --- src/store/printer/actions.js | 2 +- src/store/printer/mutations.js | 12 +++++++++++- src/store/server/mutations.js | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/store/printer/actions.js b/src/store/printer/actions.js index 2a5b771b..a360e15a 100644 --- a/src/store/printer/actions.js +++ b/src/store/printer/actions.js @@ -3,7 +3,7 @@ import Vue from 'vue' export default { reset({ commit }) { commit('reset') - //commit('tempHistory/reset') + commit('tempHistory/reset') }, init() { diff --git a/src/store/printer/mutations.js b/src/store/printer/mutations.js index 2ac94dc2..eaccf781 100644 --- a/src/store/printer/mutations.js +++ b/src/store/printer/mutations.js @@ -3,7 +3,17 @@ import { getDefaultState } from './index' export default { reset(state) { - Object.assign(state, getDefaultState()) + const defaultState = getDefaultState() + + for (const key of Object.keys(state)) { + if (!(key in defaultState) && key !== "tempHistory") { + delete state[key] + } + } + + for (const [key, value] of Object.entries(defaultState)) { + Vue.set(state, key, value) + } this.dispatch('socket/clearLoadings', null, { root: true }) if (this.state.server.plugins.includes("update_manager")) diff --git a/src/store/server/mutations.js b/src/store/server/mutations.js index abe32ca8..f699bed4 100644 --- a/src/store/server/mutations.js +++ b/src/store/server/mutations.js @@ -4,6 +4,8 @@ import { getDefaultState } from './index' export default { reset(state) { Object.assign(state, getDefaultState()) + + }, setKlippyReady() {