no more verification in available versions list

This commit is contained in:
MathieuG-P
2023-01-24 22:55:25 +01:00
parent bbd26d1c12
commit 1cfef9f607
4 changed files with 39 additions and 30 deletions
@@ -41,13 +41,11 @@ export function BsVersionItem(props: {version: BSVersion}) {
)
}
const cancel = () => {
const versionDownload = downloaderService.currentBsVersionDownload$.value;
downloaderService.cancelDownload().then(async res => {
if(!res.success){ return; }
if(!downloaderService.isVerification){
bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions());
}
const cancel = () => {
const versionDownload = downloaderService.currentBsVersionDownload$.value;
downloaderService.cancelDownload().then(async res => {
if(!res.success){ return; }
bsUninstallerService.uninstall(versionDownload).then(res => res && verionManagerService.askInstalledVersions());
});
}
@@ -31,7 +31,7 @@ export function AvailableVersionsList() {
const startDownload = () => {
setDownloading(() => true)
bsDownloaderService.download(versionSelected, versionManagerService.isVersionInstalled(versionSelected)).finally(() => {
bsDownloaderService.download(versionSelected).finally(() => {
setDownloading(() => false);
});
}
@@ -91,7 +91,7 @@ export function AvailableVersionsList() {
<AnimatePresence>
{ versionSelected && !downloading && (
<motion.div initial={{y:"150%"}} animate={{y:"0%"}} exit={{y:"150%"}} className="absolute bottom-5" onClick={startDownload}>
<BsmButton text={versionManagerService.isVersionInstalled(versionSelected) ? "misc.verify" : "misc.download"} className="relative text-gray-800 dark:text-gray-100 rounded-md text-3xl font-bold italic tracking-wide px-3 pb-2 pt-1 shadow-md shadow-black"/>
<BsmButton text="misc.download" className="relative text-gray-800 dark:text-gray-100 rounded-md text-3xl font-bold italic tracking-wide px-3 pb-2 pt-1 shadow-md shadow-black"/>
</motion.div>
)}
</AnimatePresence>
@@ -25,8 +25,6 @@ export class BsDownloaderService{
private readonly notificationService: NotificationService;
private readonly linkOpener: LinkOpenerService;
private _isVerification: boolean = false;
public readonly currentBsVersionDownload$: BehaviorSubject<BSVersion> = new BehaviorSubject(null);
public readonly downloadProgress$: BehaviorSubject<number> = new BehaviorSubject(0);
public readonly selectedBsVersion$: BehaviorSubject<BSVersion> = new BehaviorSubject(null);
@@ -71,10 +69,15 @@ export class BsDownloaderService{
this.ipcService.sendLazy('bs-download.[2FA]', {args: res.data});
});
this.ipcService.watch<BSVersion>("start-download-version").subscribe(res => {
this.currentBsVersionDownload$.next(res.data);
});
this.currentBsVersionDownload$.subscribe(version => {
if(version){ this.bsVersionManager.setInstalledVersions([...this.bsVersionManager.installedVersions$.value, version]); }
else{ this.bsVersionManager.askInstalledVersions(); }
});
}
private resetDownload(): void{
@@ -91,7 +94,7 @@ export class BsDownloaderService{
return this.ipcService.send<boolean>("is-dotnet-6-installed").then(res => res.success && res.data)
}
public async download(bsVersion: BSVersion, isVerification?: boolean, isFirstCall = true): Promise<IpcResponse<DownloadEvent>>{
public async download(bsVersion: BSVersion, isFirstCall = true): Promise<IpcResponse<DownloadEvent>>{
if(isFirstCall && !this.progressBarService.require()){ return {success: false}; }
if(isFirstCall && !(await this.isDotNet6Installed())){
@@ -111,7 +114,6 @@ export class BsDownloaderService{
}
this.progressBarService.show(this.downloadProgress$);
this._isVerification = !!isVerification;
let promise;
if(!this.authService.sessionExist()){
@@ -127,25 +129,22 @@ export class BsDownloaderService{
promise = this.ipcService.send<DownloadEvent>('bs-download.start', {args: {bsVersion, username: this.authService.getSteamUsername()}});
}
this.currentBsVersionDownload$.next(bsVersion);
let res = await promise;
if(res.data?.type === "[Password]"){
this.authService.deleteSteamSession();
res = await this.download(bsVersion, isVerification, false);
res = await this.download(bsVersion, false);
}
this.progressBarService.hide(true);
this.resetDownload();
if(res.success && isFirstCall){ this.notificationService.notifySuccess({title: `notifications.bs-download.success.titles.${isVerification ? "verification-finished" : "download-success"}`, duration: 3000}); }
if(res.success && isFirstCall){ this.notificationService.notifySuccess({title: "notifications.bs-download.success.titles.download-success", duration: 3000}); }
else if(res.data && isFirstCall){ this.notificationService.notifyError({title: `notifications.types.error`, desc: `notifications.bs-download.errors.msg.${res.data}`, duration: 3000}); }
return res;
}
public get isDownloading(): boolean{ return !!this.currentBsVersionDownload$.value; }
public get isVerification(): boolean{ return this._isVerification; }
public async getInstallationFolder(): Promise<string>{
const res = await this.ipcService.send<string>("bs-download.installation-folder");