Skip to content

Commit

Permalink
refactor: spoolman socket actions
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas committed Oct 2, 2023
1 parent 2cee275 commit 0ee1748
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
22 changes: 12 additions & 10 deletions src/api/socketActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,24 @@ export const SocketActions = {
)
},

async spoolmanState () {
async serverSpoolmanGetSpoolId () {
baseEmit(
'server.spoolman.get_spool_id', {
dispatch: 'spoolman/onActiveSpool'
}
)
},

async serverSpoolmanPostSpoolId (spoolId: number | undefined) {
baseEmit(
'server.spoolman.post_spool_id', {
params: { spool_id: spoolId },
dispatch: 'spoolman/onActiveSpool'
}
)
},

async serverSpoolmanProxyGetAvailableSpools () {
baseEmit(
'server.spoolman.proxy', {
params: {
Expand All @@ -720,14 +731,5 @@ export const SocketActions = {
dispatch: 'spoolman/onAvailableSpools'
}
)
},

async spoolmanSetSpool (spoolId: number | undefined) {
baseEmit(
'server.spoolman.post_spool_id', {
params: { spool_id: spoolId },
dispatch: 'spoolman/onActiveSpool'
}
)
}
}
2 changes: 1 addition & 1 deletion src/components/widgets/spoolman/SpoolSelectionDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export default class SpoolSelectionDialog extends Mixins(StateMixin, BrowserMixi
}
}
await SocketActions.spoolmanSetSpool(this.selectedSpool ?? undefined)
await SocketActions.serverSpoolmanPostSpoolId(this.selectedSpool ?? undefined)
if (this.filename) {
await SocketActions.printerPrintStart(this.filename)
Expand Down
7 changes: 2 additions & 5 deletions src/store/spoolman/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const actions: ActionTree<SpoolmanState, RootState> = {
* Make a socket request to init the spoolman component.
*/
async init () {
SocketActions.spoolmanState()
SocketActions.serverSpoolmanGetSpoolId()
SocketActions.serverSpoolmanProxyGetAvailableSpools()
},

async onActiveSpool ({ commit }, payload) {
Expand All @@ -24,9 +25,5 @@ export const actions: ActionTree<SpoolmanState, RootState> = {

async onAvailableSpools ({ commit }, payload) {
commit('setAvailableSpools', [...payload])
},

async notifyActiveSpoolSet ({ commit }, payload) {
commit('setActiveSpool', payload.spool_id)
}
}

0 comments on commit 0ee1748

Please sign in to comment.