fix(farm): fix switching to other printer function (#1865)

This commit is contained in:
Stefan Dej
2024-05-01 09:57:38 +02:00
committed by GitHub
parent 9bf856e7a8
commit 3afa733050
2 changed files with 9 additions and 2 deletions

View File

@@ -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() {

View File

@@ -19,6 +19,7 @@ export const actions: ActionTree<RootState, RootState> = {
dispatch('socket/setSocket', {
hostname: printerSocket.hostname,
port: printerSocket.port,
path: printerSocket.path,
})
},