From db03190c34aa21c0b3388778722cadc7ba87d8fb Mon Sep 17 00:00:00 2001 From: Mathis Mensing Date: Fri, 28 Jul 2023 19:31:02 +0200 Subject: [PATCH] refactor: update spool id on open Signed-off-by: Mathis Mensing --- .../widgets/spoolman/SpoolSelectionDialog.vue | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/components/widgets/spoolman/SpoolSelectionDialog.vue b/src/components/widgets/spoolman/SpoolSelectionDialog.vue index a71b1492aa..2b5316cd91 100644 --- a/src/components/widgets/spoolman/SpoolSelectionDialog.vue +++ b/src/components/widgets/spoolman/SpoolSelectionDialog.vue @@ -6,8 +6,6 @@ :max-width="isMobileViewport ? '90vw' : '75vw'" > - -
@@ -198,7 +196,7 @@ import { CameraConfig } from '@/store/cameras/types' }) export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixin) { search = '' - selectedSpoolId = this.$store.state.spoolman.activeSpool ?? null + selectedSpoolId: number | null = null cameraScanSource: null | string = null cameraSelectionMenuOpen = false @@ -206,6 +204,8 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi @Watch('open') onOpen () { if (this.open) { + this.selectedSpoolId = this.$store.state.spoolman.activeSpool + if (this.currentFileName) { // prefetch file metadata SocketActions.serverFilesMetadata(this.currentFileName) @@ -262,12 +262,8 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi return this.selectedSpoolId } - set selectedSpool (id: number) { - if (this.selectedSpoolId === id) { - this.selectedSpoolId = undefined - } else { - this.selectedSpoolId = id - } + set selectedSpool (id: number | null) { + this.selectedSpoolId = id } get filename () { @@ -388,7 +384,7 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi } } - await SocketActions.spoolmanSetSpool(this.selectedSpool) + await SocketActions.spoolmanSetSpool(this.selectedSpool ?? undefined) if (this.filename) { await SocketActions.printerPrintStart(this.filename)