Skip to content

Commit

Permalink
fix(Charts): reset chart store on moonraker reset
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <pedrolamas@gmail.com>
  • Loading branch information
pedrolamas committed Nov 8, 2024
1 parent 7d5b664 commit 24d0db9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/store/socket/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ export const actions: ActionTree<SocketState, RootState> = {
*/
async onSocketClose ({ dispatch, commit, state }, event: CloseEvent) {
const retry = state.disconnecting
const modules = ['server', 'power', 'webcams', 'jobQueue', 'charts', 'socket', 'wait', 'gcodePreview']
const modules = ['server', 'power', 'webcams', 'jobQueue', 'socket', 'wait', 'gcodePreview']

if (event.wasClean && retry) {
// This is most likely a moonraker restart, so only partially reset.
await dispatch('reset', modules, { root: true })
await Promise.all([
dispatch('charts/resetChartStore', undefined, { root: true }),
dispatch('reset', modules, { root: true })
])
commit('setSocketConnecting', true)
Vue.$socket.connect()
}
Expand All @@ -67,7 +70,10 @@ export const actions: ActionTree<SocketState, RootState> = {
if (!event.wasClean) {
// Not a clean disconnect. Service went down?
// Socket should attempt to reconnect itself.
await dispatch('reset', modules, { root: true })
await Promise.all([
dispatch('charts/resetChartStore', undefined, { root: true }),
dispatch('reset', modules, { root: true })
])
commit('setSocketConnecting', true)
commit('setSocketOpen', false)
}
Expand Down

0 comments on commit 24d0db9

Please sign in to comment.