From 1d401008e05133f6d58fbc52cbd241f24b79cde8 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Tue, 30 Apr 2024 21:39:45 +0200 Subject: [PATCH] fix(farm): fix switching to other printer function Signed-off-by: Stefan Dej --- src/components/panels/FarmPrinterPanel.vue | 10 ++++++++-- src/store/actions.ts | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/panels/FarmPrinterPanel.vue b/src/components/panels/FarmPrinterPanel.vue index bcfb55959..44dc4c9f6 100644 --- a/src/components/panels/FarmPrinterPanel.vue +++ b/src/components/panels/FarmPrinterPanel.vue @@ -228,8 +228,14 @@ export default class FarmPrinterPanel extends Mixins(BaseMixin, ThemeMixin, Webc } clickPrinter() { - if (this.printer.socket.isConnected) this.$store.dispatch('changePrinter', { printer: this.printer._namespace }) - else this.$store.dispatch('farm/' + this.printer._namespace + '/reconnect') + // If the printer is already connected, just switch to it + if (this.printer.socket.isConnected) { + this.$store.dispatch('changePrinter', { printer: this.printer._namespace }) + return + } + + // Otherwise, reconnect to the printer + this.$store.dispatch('farm/' + this.printer._namespace + '/reconnect') } mounted() { diff --git a/src/store/actions.ts b/src/store/actions.ts index ba07f8d86..05ddc62d7 100644 --- a/src/store/actions.ts +++ b/src/store/actions.ts @@ -19,6 +19,7 @@ export const actions: ActionTree = { dispatch('socket/setSocket', { hostname: printerSocket.hostname, port: printerSocket.port, + path: printerSocket.path, }) },