no other operation when an operation is running

This commit is contained in:
MathieuG-P
2022-07-31 18:12:24 +02:00
parent d880416d6c
commit 5d848859e5
9 changed files with 51 additions and 7 deletions
+10
View File
@@ -72,6 +72,16 @@
"warning": "⚠️ Warning",
"success": "🎉 Success"
},
"shared":{
"errors":{
"titles":{
"operation-running": "Operation running"
},
"msg":{
"operation-running": "Wait for the end of the current operation then start again."
}
}
},
"bs-download":{
"success":{
"titles":{
+10
View File
@@ -73,6 +73,16 @@
"warning": "⚠️ Advertencia",
"success": "🎉 Éxito"
},
"shared":{
"errors":{
"titles":{
"operation-running": "Operación en curso"
},
"msg":{
"operation-running": "Espere a que termine la operación actual y vuelva a empezar."
}
}
},
"bs-download":{
"success":{
"titles":{
+10
View File
@@ -72,6 +72,16 @@
"warning": "⚠️ Attention",
"success": "🎉 Succès"
},
"shared":{
"errors":{
"titles":{
"operation-running": "Opération en cours"
},
"msg":{
"operation-running": "Attend la fin de l'opération en cours puis recommences."
}
}
},
"bs-download":{
"success":{
"titles":{
+1 -2
View File
@@ -139,8 +139,7 @@ export class BSInstallerService{
reject(err);
});
this.downloadProcess.on('close', (code) => reject({type: "[Exit]", data: code}));
this.downloadProcess.on('close', () => reject());
})
}
@@ -43,7 +43,7 @@ export class InstallationLocationService {
const oldDir = this.installationDirectory;
const newDest = path.join(newDir, this.INSTALLATION_FOLDER);
return new Promise<string>((resolve, reject) => {
if(!this.utilsService.folderExist(oldDir)){ this.utilsService.createFolderIfNotExist(oldDir); }
if(!this.utilsService.pathExist(oldDir)){ this.utilsService.createFolderIfNotExist(oldDir); }
fs.move(oldDir, newDest, { overwrite: true }).then(() => {
this._installationDirectory = newDir;
this.configService.store.set(this.STORE_INSTALLATION_PATH_KEY, newDir);
@@ -74,6 +74,11 @@ export function SettingsPage() {
}
const setDefaultInstallationFolder = () => {
if(progressBarService.isVisible){
notificationService.notifyError({title: "notifications.shared.errors.titles.operation-running", desc: "notifications.shared.errors.msg.operation-running", duration: 3000});
return;
}
modalService.openModal(ModalType.INSTALLATION_FOLDER).then(async res => {
if(res.exitCode !== ModalExitCode.COMPLETED){ return; }
const fileChooserRes = await ipcService.send<{canceled: boolean, filePaths: string[]}>("choose-folder");
@@ -82,7 +82,12 @@ export class BsDownloaderService{
return this.ipcService.send<boolean>("bs-download.kill");
}
public async download(bsVersion: BSVersion, isVerification?: boolean): Promise<IpcResponse<DownloadEvent>>{
public async download(bsVersion: BSVersion, isVerification?: boolean, isFirstCall: boolean = true): Promise<IpcResponse<DownloadEvent>>{
if(isFirstCall && this.progressBarService.isVisible){
this.notificationService.notifyError({title: "notifications.shared.errors.titles.operation-running", desc: "notifications.shared.errors.msg.operation-running", duration: 3000});
return {success: false};
}
this.progressBarService.show(this.downloadProgress$);
this._isVerification = !!isVerification;
@@ -104,15 +109,15 @@ export class BsDownloaderService{
let res = await promise;
if(res.data.type === "[Password]"){
if(res.data?.type === "[Password]"){
this.authService.deleteSteamSession();
res = await this.download(bsVersion);
res = await this.download(bsVersion, isVerification, false);
}
this.progressBarService.hide(true);
this.resetDownload();
if(res.success){ this.notificationService.notifySuccess({title: `notifications.bs-download.success.titles.${isVerification ? "verification-finished" : "download-success"}`, duration: 3000}); }
else{ this.notificationService.notifyError({title: `notifications.bs-download.errors.titles.${res.data}`, duration: 3000}); }
else if(res.data){ this.notificationService.notifyError({title: `notifications.bs-download.errors.titles.${res.data}`, duration: 3000}); }
return res;
}
@@ -88,6 +88,10 @@ export class BSVersionManagerService {
}
public async cloneVersion(version: BSVersion): Promise<BSVersion>{
if(this.progressBarService.isVisible){
this.notificationService.notifyError({title: "notifications.shared.errors.titles.operation-running", desc: "notifications.shared.errors.msg.operation-running", duration: 3000});
return null;
}
const modalRes = await this.modalService.openModal<{name: string, color: string}>(ModalType.CLONE_VERSION, version);
if(modalRes.exitCode !== ModalExitCode.COMPLETED){ return null; }
if(modalRes.data.name?.length < 2){ return null; }
@@ -70,6 +70,7 @@ export class ProgressBarService{
public get progression$(): BehaviorSubject<number>{ return this._progression$; }
public get visible$(): BehaviorSubject<boolean>{ return this._visible$; }
public get isVisible(): boolean{ return this._visible$.value; }