Skip to content

Commit

Permalink
fix: allow null as spool id response from spoolman (#1611)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Oct 18, 2023
1 parent 5cd5aa4 commit f35252e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/dialogs/SpoolmanEjectSpoolDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class SpoolmanEjectSpoolDialog extends Mixins(BaseMixin) {
}
removeSpool() {
this.$store.dispatch('server/spoolman/setActiveSpool', 0)
this.$store.dispatch('server/spoolman/setActiveSpool', null)
this.close()
}
}
Expand Down
11 changes: 6 additions & 5 deletions src/store/server/spoolman/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export const actions: ActionTree<ServerSpoolmanState, RootState> = {
commit('setActiveSpoolId', payload.spool_id)
dispatch('socket/removeInitModule', 'server/spoolman/getActiveSpoolId', { root: true })

// also set active spool to null, if spool_id is 0
if (payload.spool_id === 0) {
// also set active spool to null, if spool_id is 0 or null
if ([null, 0].includes(payload.spool_id)) {
commit('setActiveSpool', null)
return
}
Expand Down Expand Up @@ -112,9 +112,10 @@ export const actions: ActionTree<ServerSpoolmanState, RootState> = {
},

setActiveSpool(_, id: number | null) {
Vue.$socket.emit('server.spoolman.post_spool_id', {
spool_id: id,
})
const params: { spool_id?: number } = {}
if (id !== null) params['spool_id'] = id

Vue.$socket.emit('server.spoolman.post_spool_id', params)
},

refreshActiveSpool({ state }) {
Expand Down

0 comments on commit f35252e

Please sign in to comment.