Skip to content

Commit

Permalink
fix(Charts): allow resetting chart store only (#1514)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas authored Oct 25, 2024
1 parent 3a51637 commit 76dc3fd
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
4 changes: 0 additions & 4 deletions src/components/widgets/thermals/TemperatureTargets.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,6 @@ import type { ChartData, ChartSelectedLegends } from '@/store/charts/types'
}
})
export default class TemperatureTargets extends Mixins(StateMixin) {
get extruder () {
return this.$store.state.printer.printer.extruder
}
get heaters () {
return this.$store.getters['printer/getHeaters']
}
Expand Down
8 changes: 1 addition & 7 deletions src/mixins/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ export default class ServicesMixin extends Vue {
* Resets the UI when restarting/resetting Klipper
*/
async _klipperReset () {
this.$store.commit('socket/setAcceptNotifications', false)
await this.$store.dispatch('server/resetKlippy', undefined, { root: true })
await this.$store.dispatch('reset', [
'printer',
'charts',
'wait'
], { root: true })
await this.$store.dispatch('resetKlippy', undefined, { root: true })
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/store/charts/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export const actions: ActionTree<ChartState, RootState> = {
commit('setReset')
},

async resetChartStore ({ commit }) {
commit('setResetChartStore')
},

/**
* Loads stored server data for the past 20 minutes.
*/
Expand Down
9 changes: 9 additions & 0 deletions src/store/charts/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ export const mutations: MutationTree<ChartState> = {
Object.assign(state, defaultState())
},

setResetChartStore (state) {
const { chart, ready } = defaultState()

Object.assign(state, {
chart,
ready
})
},

/**
* Init the chart store from db
*/
Expand Down
13 changes: 13 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ export default new Vuex.Store<RootState>({
commit('config/setAppReady', true)
},

async resetKlippy ({ dispatch, commit }) {
commit('socket/setAcceptNotifications', false)

await Promise.all([
dispatch('server/resetKlippy'),
dispatch('charts/resetChartStore'),
dispatch('reset', [
'printer',
'wait'
])
])
},

/**
* A void action. Some socket commands may not need processing.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/store/socket/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ export const actions: ActionTree<SocketState, RootState> = {
/**
* This is fired when, for example - the service is stopped.
*/
async notifyKlippyDisconnected () {
async notifyKlippyDisconnected ({ dispatch }) {
await dispatch('resetKlippy', undefined, { root: true })

SocketActions.serverInfo()
},

Expand Down

0 comments on commit 76dc3fd

Please sign in to comment.