From 7ef52b5e9f8aca913a7ed4bf30ab43341b22e722 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Mon, 16 Oct 2023 22:53:41 +0200 Subject: [PATCH 1/2] fix: allow null as spool id response from spoolman Signed-off-by: Stefan Dej --- src/store/server/spoolman/actions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/server/spoolman/actions.ts b/src/store/server/spoolman/actions.ts index 6553cd8d2..c6aa30ee5 100644 --- a/src/store/server/spoolman/actions.ts +++ b/src/store/server/spoolman/actions.ts @@ -47,8 +47,8 @@ export const actions: ActionTree = { 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 } From 674cec26babba716c17ce14b486e6176ae64d652 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 17 Oct 2023 23:44:10 +0200 Subject: [PATCH 2/2] fix: send empty object to eject spool Signed-off-by: Stefan Dej --- src/components/dialogs/SpoolmanEjectSpoolDialog.vue | 2 +- src/store/server/spoolman/actions.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/dialogs/SpoolmanEjectSpoolDialog.vue b/src/components/dialogs/SpoolmanEjectSpoolDialog.vue index 14200f2a0..479ef136f 100644 --- a/src/components/dialogs/SpoolmanEjectSpoolDialog.vue +++ b/src/components/dialogs/SpoolmanEjectSpoolDialog.vue @@ -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() } } diff --git a/src/store/server/spoolman/actions.ts b/src/store/server/spoolman/actions.ts index c6aa30ee5..510c23c75 100644 --- a/src/store/server/spoolman/actions.ts +++ b/src/store/server/spoolman/actions.ts @@ -112,9 +112,10 @@ export const actions: ActionTree = { }, 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 }) {