Clear completed button; reset overall progress after completed downloads

This commit is contained in:
Geomitron
2021-04-10 13:43:26 -05:00
parent 36803a5d0c
commit 8f670c5adc
5 changed files with 50 additions and 5 deletions

View File

@@ -30,12 +30,20 @@ export class DownloadService {
return this.downloads.length
}
get totalPercent() {
get completedCount() {
return this.downloads.filter(download => download.type == 'done').length
}
get totalDownloadingPercent() {
let total = 0
let count = 0
for (const download of this.downloads) {
total += download.percent
if (!download.stale) {
total += download.percent
count++
}
}
return total / this.downloads.length
return total / count
}
get anyErrorsExist() {
@@ -44,6 +52,9 @@ export class DownloadService {
addDownload(versionID: number, newDownload: NewDownload) {
if (!this.downloads.find(download => download.versionID == versionID)) { // Don't download something twice
if (this.downloads.every(download => download.type == 'done')) { // Reset overall progress bar if it finished
this.downloads.forEach(download => download.stale = true)
}
this.electronService.sendIPC('download', { action: 'add', versionID, data: newDownload })
}
}
@@ -63,6 +74,14 @@ export class DownloadService {
}
}
cancelCompleted() {
for (const download of this.downloads) {
if (download.type == 'done') {
this.cancelDownload(download.versionID)
}
}
}
retryDownload(versionID: number) {
this.electronService.sendIPC('download', { action: 'retry', versionID })
}