emit download errors

This commit is contained in:
SpikeHD
2022-05-11 21:18:07 -07:00
parent 3ee8ee7061
commit 4b95c52b6c
7 changed files with 78 additions and 16 deletions

View File

@@ -8,6 +8,7 @@ export default class DownloadHandler {
progress: number,
total: number,
status: string,
error?: string,
}[]
// Pass tauri invoke function
@@ -35,6 +36,19 @@ export default class DownloadHandler {
const index = this.downloads.findIndex(download => download.path === filename)
this.downloads[index].status = 'finished'
})
listen('download_error', (...payload) => {
// @ts-expect-error shut up typescript
const errorData: {
path: string,
error: string,
} = payload[0]?.payload
// Set download to error
const index = this.downloads.findIndex(download => download.path === errorData.path)
this.downloads[index].status = 'error'
this.downloads[index].error = errorData.error
})
}
getDownloads() {