Skip to content

Commit

Permalink
fix: don't show gcode load dialog if canceled (#1128)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas authored Jul 24, 2023
1 parent f9ef7c5 commit 080bb46
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/widgets/filesystem/FileSystem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,9 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
async handlePreviewGcode (file: AppFile | AppFileWithMeta) {
this.getGcode(file)
.then(response => response?.data)
.then((gcode) => {
.then(gcode => {
if (!gcode) return
if (this.$router.currentRoute.path !== '/' || !this.$store.getters['layout/isEnabledInCurrentLayout']('gcode-preview-card')) {
this.$router.push({ path: '/preview' })
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/widgets/gcode-preview/GcodePreviewCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ export default class GcodePreviewCard extends Mixins(StateMixin, FilesMixin, Bro
this.getGcode(file)
.then(response => response?.data)
.then(gcode => {
if (!gcode) return
this.$store.dispatch('gcodePreview/loadGcode', {
file,
gcode
Expand Down
6 changes: 3 additions & 3 deletions src/mixins/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class FilesMixin extends Vue {
this.$store.dispatch('files/createFileTransferCancelTokenSource')

const path = file.path ? `gcodes/${file.path}` : 'gcodes'
return await this.getFile(file.filename, path, file.size, {
return await this.getFile<string>(file.filename, path, file.size, {
responseType: 'text',
transformResponse: [v => v],
cancelToken: this.cancelTokenSource.token
Expand All @@ -100,7 +100,7 @@ export default class FilesMixin extends Vue {
* @param filename The filename to retrieve
* @param path The path to the file
*/
async getFile (filename: string, path: string, size = 0, options?: AxiosRequestConfig) {
async getFile<T = any> (filename: string, path: string, size = 0, options?: AxiosRequestConfig) {
// Sort out the filepath
const filepath = path ? `${path}/${filename}` : filename

Expand Down Expand Up @@ -148,7 +148,7 @@ export default class FilesMixin extends Vue {
}
}

return await httpClientActions.serverFilesGet(filepath, o)
return await httpClientActions.serverFilesGet<T>(filepath, o)
}

/**
Expand Down

0 comments on commit 080bb46

Please sign in to comment.