diff --git a/src/main/services/bs-installer.service.ts b/src/main/services/bs-installer.service.ts index 30b5eabc..aa04da37 100644 --- a/src/main/services/bs-installer.service.ts +++ b/src/main/services/bs-installer.service.ts @@ -94,11 +94,13 @@ export class BSInstallerService{ console.log(match); const out = match.split("|"); - if(out[0] === DownloadEventType.NOT_LOGGED_IN && downloadInfos.password){ setTimeout(() => {this.sendInputProcess(downloadInfos.password); console.log("*** LOGIN ***")}, 5000) } + if(out[0] === DownloadEventType.NOT_LOGGED_IN && downloadInfos.password){ this.sendInputProcess(downloadInfos.password); console.log("*** LOGIN ***"); } else if(out[0] === DownloadEventType.NOT_LOGGED_IN){ this.downloadProcess.kill(); this.utils.ipcSend(`bs-download.${DownloadEventType.NOT_LOGGED_IN}`); } else if(out[0] === DownloadEventType.GUARD_CODE){ this.utils.ipcSend(`bs-download.${DownloadEventType.GUARD_CODE}`); } else if(out[0] === DownloadEventType.TWO_FA_CODE){ this.utils.ipcSend(`bs-download.${DownloadEventType.TWO_FA_CODE}`); } - else if(out[0] === DownloadEventType.PROGESS){ this.utils.ipcSend(`bs-download.${DownloadEventType.PROGESS}`, parseFloat(out[1])); } + else if(out[0] === DownloadEventType.PROGESS){ + this.utils.ipcSend(`bs-download.${DownloadEventType.PROGESS}`, parseFloat(out[1])); + } else if(out[0] === DownloadEventType.FINISH){ this.utils.ipcSend(`bs-download.${DownloadEventType.FINISH}`); this.downloadProcess.kill(); } else if(out[0] === DownloadEventType.ERROR){ console.log("ERROR"); diff --git a/src/renderer/services/bs-downloader.service.ts b/src/renderer/services/bs-downloader.service.ts index 27d192dd..4cb7b88b 100644 --- a/src/renderer/services/bs-downloader.service.ts +++ b/src/renderer/services/bs-downloader.service.ts @@ -12,12 +12,15 @@ export class BsDownloaderService{ private readonly bsVersionManager: BSVersionManagerService = BSVersionManagerService.getInstance(); private readonly downloadedVersions$: BehaviorSubject = new BehaviorSubject([]); + private readonly currentBsVersionDownload$: BehaviorSubject = new BehaviorSubject(null); + private readonly downloadProgress$: BehaviorSubject = 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); } }