Skip to content

Commit 080bb46

Browse files
authored
fix: don't show gcode load dialog if canceled (#1128)
Signed-off-by: Pedro Lamas <[email protected]>
1 parent f9ef7c5 commit 080bb46

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/components/widgets/filesystem/FileSystem.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,9 @@ export default class FileSystem extends Mixins(StateMixin, FilesMixin, ServicesM
691691
async handlePreviewGcode (file: AppFile | AppFileWithMeta) {
692692
this.getGcode(file)
693693
.then(response => response?.data)
694-
.then((gcode) => {
694+
.then(gcode => {
695+
if (!gcode) return
696+
695697
if (this.$router.currentRoute.path !== '/' || !this.$store.getters['layout/isEnabledInCurrentLayout']('gcode-preview-card')) {
696698
this.$router.push({ path: '/preview' })
697699
}

src/components/widgets/gcode-preview/GcodePreviewCard.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ export default class GcodePreviewCard extends Mixins(StateMixin, FilesMixin, Bro
315315
this.getGcode(file)
316316
.then(response => response?.data)
317317
.then(gcode => {
318+
if (!gcode) return
319+
318320
this.$store.dispatch('gcodePreview/loadGcode', {
319321
file,
320322
gcode

src/mixins/files.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default class FilesMixin extends Vue {
8787
this.$store.dispatch('files/createFileTransferCancelTokenSource')
8888

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

@@ -148,7 +148,7 @@ export default class FilesMixin extends Vue {
148148
}
149149
}
150150

151-
return await httpClientActions.serverFilesGet(filepath, o)
151+
return await httpClientActions.serverFilesGet<T>(filepath, o)
152152
}
153153

154154
/**

0 commit comments

Comments
 (0)