add progression when download

This commit is contained in:
MathieuG-P
2022-05-23 23:44:04 +02:00
parent 788d9d1a05
commit 7fb4bc012d
2 changed files with 12 additions and 2 deletions
@@ -12,12 +12,15 @@ export class BsDownloaderService{
private readonly bsVersionManager: BSVersionManagerService = BSVersionManagerService.getInstance();
private readonly downloadedVersions$: BehaviorSubject<BSVersion[]> = new BehaviorSubject([]);
private readonly currentBsVersionDownload$: BehaviorSubject<BSVersion> = new BehaviorSubject(null);
private readonly downloadProgress$: BehaviorSubject<number> = new BehaviorSubject(0);
private constructor(){
window.electron.ipcRenderer.on(`bs-download.[Password]`, async (bsVersion: BSVersion) => {
const res = await this.modalService.openModal(ModalType.STEAM_LOGIN);
if(res.exitCode !== ModalExitCode.COMPLETED){ return; }
window.electron.ipcRenderer.sendMessage('bs-download.start', {bsVersion: bsVersion, username: res.data.username, password: res.data.password, stay: res.data.stay} as DownloadInfo)
this.currentBsVersionDownload$.next(bsVersion);
});
window.electron.ipcRenderer.on("bs-download.[Guard]", async () => {
@@ -29,6 +32,10 @@ export class BsDownloaderService{
window.electron.ipcRenderer.on("bs-download.[Finished]", async () => {
this.bsVersionManager.askInstalledVersions();
});
window.electron.ipcRenderer.on("bs-download.[Progress]", async (progress: number) => {
this.downloadProgress$.next(progress);
})
}
public static getInstance(){
@@ -47,6 +54,7 @@ export class BsDownloaderService{
else{
window.electron.ipcRenderer.sendMessage('bs-download.start', {bsVersion: bsVersion, username: username} as DownloadInfo);
}
this.currentBsVersionDownload$.next(bsVersion);
}
}