mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-14 07:10:35 +00:00
More download bugfixes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Component, ChangeDetectorRef } from '@angular/core'
|
||||
import { DownloadProgress } from '../../../../../electron/shared/interfaces/download.interface'
|
||||
import { DownloadService } from '../../../../core/services/download.service'
|
||||
import { ElectronService } from 'src/app/core/services/electron.service'
|
||||
import { ElectronService } from '../../../../core/services/electron.service'
|
||||
|
||||
@Component({
|
||||
selector: 'app-downloads-modal',
|
||||
@@ -13,6 +13,10 @@ export class DownloadsModalComponent {
|
||||
downloads: DownloadProgress[] = []
|
||||
|
||||
constructor(private electronService: ElectronService, private downloadService: DownloadService, ref: ChangeDetectorRef) {
|
||||
electronService.receiveIPC('queue-updated', (order) => {
|
||||
this.downloads.sort((a, b) => order.indexOf(a.versionID) - order.indexOf(b.versionID))
|
||||
})
|
||||
|
||||
downloadService.onDownloadUpdated(download => {
|
||||
const index = this.downloads.findIndex(thisDownload => thisDownload.versionID == download.versionID)
|
||||
if (index == -1) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Injectable, EventEmitter } from '@angular/core'
|
||||
import { ElectronService } from './electron.service'
|
||||
import { NewDownload, DownloadProgress } from '../../../electron/shared/interfaces/download.interface'
|
||||
import * as _ from 'underscore'
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -46,14 +45,7 @@ export class DownloadService {
|
||||
}
|
||||
|
||||
onDownloadUpdated(callback: (download: DownloadProgress) => void) {
|
||||
const debouncedCallback = _.throttle(callback, 30, { trailing: false })
|
||||
this.downloadUpdatedEmitter.subscribe((download: DownloadProgress) => {
|
||||
if (download.type == 'fastUpdate') { // 'good' updates can happen so frequently that the UI doesn't update correctly
|
||||
debouncedCallback(download)
|
||||
} else {
|
||||
callback(download)
|
||||
}
|
||||
})
|
||||
this.downloadUpdatedEmitter.subscribe(callback)
|
||||
}
|
||||
|
||||
cancelDownload(versionID: number) {
|
||||
|
||||
Reference in New Issue
Block a user