Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading