mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 22:29:38 +00:00
Clear completed button; reset overall progress after completed downloads
This commit is contained in:
@@ -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 })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user