Skip to content

Commit

Permalink
fix(farm): fix switching to other printer function (#1865)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored May 1, 2024
1 parent 9bf856e commit 3afa733
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/panels/FarmPrinterPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions src/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const actions: ActionTree<RootState, RootState> = {
dispatch('socket/setSocket', {
hostname: printerSocket.hostname,
port: printerSocket.port,
path: printerSocket.path,
})
},

Expand Down

0 comments on commit 3afa733

Please sign in to comment.