improve downloads dialog

This commit is contained in:
SpikeHD
2022-05-11 21:27:43 -07:00
parent 4fa269d75e
commit cd4fe6b9fb
3 changed files with 15 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import { invoke } from '@tauri-apps/api/tauri'
import { listen } from '@tauri-apps/api/event'
import { byteToString } from './string'
export default class DownloadHandler {
downloads: {
@@ -73,6 +74,11 @@ export default class DownloadHandler {
return this.downloads[index] || null
}
getDownloadSize(path: string) {
const index = this.downloads.findIndex(download => download.path === path)
return byteToString(this.downloads[index].total) || null
}
getTotalAverage() {
const files = this.downloads.filter(d => d.status !== 'finished')
const total = files.reduce((acc, d) => acc + d.total, 0)