mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
fix bs version download bugs
This commit is contained in:
@@ -31,8 +31,8 @@ ipcMain.on('bs-download.start', async (event, request: IpcRequest<DownloadInfo>)
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on(`bs-download.${"[2FA]" as DownloadEventType}`, async (event, args) => {
|
||||
BSInstallerService.getInstance().sendInputProcess(args);
|
||||
ipcMain.on(`bs-download.${"[2FA]" as DownloadEventType}`, async (event, args: IpcRequest<string>) => {
|
||||
BSInstallerService.getInstance().sendInputProcess(args.args);
|
||||
});
|
||||
|
||||
ipcMain.on('bs-download.installation-folder', async (event, request: IpcRequest<void>) => {
|
||||
|
||||
@@ -104,10 +104,10 @@ export class BSInstallerService{
|
||||
resolve({type: "[Password]", data: bsVersion});
|
||||
}
|
||||
else if(out[0] === "[Guard]" as DownloadEventType){
|
||||
resolve({type: "[2FA]"});
|
||||
this.utils.newIpcSenc(`bs-download.${"[2FA]" as DownloadEventType}`, {success: true});
|
||||
}
|
||||
else if(out[0] === "[2FA]" as DownloadEventType){
|
||||
resolve({type: "[2FA]"});
|
||||
this.utils.newIpcSenc(`bs-download.${"[2FA]" as DownloadEventType}`, {success: true});
|
||||
}
|
||||
else if(out[0] === "[Progress]" as DownloadEventType || (out[0] === "[Validated]" as DownloadEventType && parseFloat(out[1]) < 100)){
|
||||
this.utils.newIpcSenc(`bs-download.${"[Progress]" as DownloadEventType}`, {success: true, data: parseFloat(out[1])});
|
||||
|
||||
@@ -45,6 +45,13 @@ export class BsDownloaderService{
|
||||
|
||||
this.ipcService.watch<string>("bs-download.[Warning]").subscribe(response => response.success && this.downloadWarning$.next(response.data));
|
||||
|
||||
this.ipcService.watch<void>("bs-download.[2FA]").subscribe(async response => {
|
||||
if(!response.success){ return; }
|
||||
const res = await this.modalService.openModal(ModalType.GUARD_CODE);
|
||||
if(res.exitCode !== ModalExitCode.COMPLETED){ return; }
|
||||
this.ipcService.sendLazy('bs-download.[2FA]', {args: res.data});
|
||||
});
|
||||
|
||||
this.currentBsVersionDownload$.subscribe(version => {
|
||||
if(version){ this.bsVersionManager.setInstalledVersions([...this.bsVersionManager.installedVersions$.value, version]); }
|
||||
else{ this.bsVersionManager.askInstalledVersions(); }
|
||||
@@ -57,13 +64,6 @@ export class BsDownloaderService{
|
||||
this.selectedBsVersion$.next(null);
|
||||
}
|
||||
|
||||
public async send2FA(): Promise<IpcResponse<DownloadEvent>>{
|
||||
const res = await this.modalService.openModal(ModalType.GUARD_CODE);
|
||||
if(res.exitCode !== ModalExitCode.COMPLETED){ return {success: false}; }
|
||||
|
||||
return this.ipcService.send<DownloadEvent>('bs-download.2FA', {args: res.data});
|
||||
}
|
||||
|
||||
public async download(bsVersion: BSVersion): Promise<IpcResponse<DownloadEvent>>{
|
||||
let promise;
|
||||
if(!this.authService.sessionExist()){
|
||||
@@ -75,20 +75,20 @@ export class BsDownloaderService{
|
||||
else{
|
||||
promise = this.ipcService.send<DownloadEvent>('bs-download.start', {args: {bsVersion: bsVersion, username: this.authService.getSteamUsername()}});
|
||||
}
|
||||
|
||||
this.currentBsVersionDownload$.next(bsVersion);
|
||||
|
||||
return promise.then(async res => {
|
||||
if(!res.success){ return res; }
|
||||
if(res.data.type === "[Password]"){
|
||||
this.authService.deleteSteamSession();
|
||||
res = await this.download(bsVersion);
|
||||
}
|
||||
else if(res.data.type === "[2FA]"){
|
||||
res = await this.send2FA();
|
||||
}
|
||||
this.resetDownload();
|
||||
return res;
|
||||
});
|
||||
let res = await promise;
|
||||
|
||||
if(!res.success){ return res; }
|
||||
|
||||
if(res.data.type === "[Password]"){
|
||||
this.authService.deleteSteamSession();
|
||||
res = await this.download(bsVersion);
|
||||
}
|
||||
|
||||
this.resetDownload();
|
||||
return res;
|
||||
}
|
||||
|
||||
public get isDownloading(): boolean{
|
||||
|
||||
Reference in New Issue
Block a user