Skip to content

Commit

Permalink
refactor: update spool id on open
Browse files Browse the repository at this point in the history
Signed-off-by: Mathis Mensing <[email protected]>
  • Loading branch information
matmen committed Jul 28, 2023
1 parent a4f7951 commit db03190
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/components/widgets/spoolman/SpoolSelectionDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
:max-width="isMobileViewport ? '90vw' : '75vw'"
>
<v-card>
<!-- TODO show file info? -->

<v-toolbar
dense
class="mb-2"
Expand Down Expand Up @@ -104,7 +102,7 @@
<tr
:class="{ 'v-data-table__selected': (item.id === selectedSpool) }"
class="row-select px-1"
@click.prevent="selectedSpool = item.id"
@click.prevent="selectedSpool = selectedSpool === item.id ? null : item.id"
>
<td>
<div class="d-flex">
Expand Down Expand Up @@ -198,14 +196,16 @@ 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
@Watch('open')
onOpen () {
if (this.open) {
this.selectedSpoolId = this.$store.state.spoolman.activeSpool
if (this.currentFileName) {
// prefetch file metadata
SocketActions.serverFilesMetadata(this.currentFileName)
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit db03190

Please sign in to comment.