handle no internet when download

This commit is contained in:
MathieuG-P
2022-07-31 17:15:18 +02:00
parent 3491aaee43
commit d880416d6c
6 changed files with 13 additions and 6 deletions
+2 -1
View File
@@ -91,7 +91,8 @@
"errors":{
"titles":{
"already-downloading": "A download is already in progress",
"verification-failed":"The verification failed."
"verification-failed":"The verification failed.",
"no-internet": "No internet connection."
},
"msg":{
"Password": "Password is invalid.",
+2 -1
View File
@@ -92,7 +92,8 @@
"errors":{
"titles":{
"already-downloading": "La descarga ya está en curso",
"verification-failed":"La verificación falló."
"verification-failed":"La verificación falló.",
"no-internet": "Sin conexión a Internet."
},
"msg":{
"Password": "La contraseña es inválida.",
+2 -1
View File
@@ -91,7 +91,8 @@
"errors":{
"titles":{
"already-downloading": "Un téléchargement est déjà en cours",
"verification-failed": "La vérification a échoué."
"verification-failed": "La vérification a échoué.",
"no-internet": "Pas de connexion internet."
},
"msg":{
"Password": "Le mot de passe est invalide.",
+4 -2
View File
@@ -8,6 +8,7 @@ import { InstallationLocationService } from "./installation-location.service";
import { ctrlc } from "ctrlc-windows";
import { BSLocalVersionService } from "./bs-local-version.service";
import { getMainWindow } from "../main";
import isOnline from 'is-online';
export class BSInstallerService{
@@ -62,9 +63,10 @@ export class BSInstallerService{
}
public async downloadBsVersion(downloadInfos: DownloadInfo): Promise<DownloadEvent>{
if(this.downloadProcess && !this.downloadProcess?.killed){ console.log("*** AlreadyDownloading ***"); return {type: "[AlreadyDownloading]"}; }
if(this.downloadProcess && !this.downloadProcess?.killed){ return {type: "[AlreadyDownloading]"}; }
const bsVersion = downloadInfos.bsVersion;
if(!bsVersion){ return {type: "[Error]"}; }
if(!(await isOnline({timeout: 1500}))){ throw "no-internet"; }
this.utils.createFolderIfNotExist(this.installLocationService.versionsDirectory);
this.downloadProcess = spawn(
@@ -159,4 +161,4 @@ export interface DownloadEvent{
data?: any,
}
export type DownloadEventType = "[Password]" | "[Guard]" | "[2FA]" | "[Progress]" | "[Validated]" | "[Finished]" | "[AlreadyDownloading]" | "[Error]" | "[Warning]" | "[SteamID]" | "[Exit]";
export type DownloadEventType = "[Password]" | "[Guard]" | "[2FA]" | "[Progress]" | "[Validated]" | "[Finished]" | "[AlreadyDownloading]" | "[Error]" | "[Warning]" | "[SteamID]" | "[Exit]" | "[NoInternet]";
@@ -111,7 +111,8 @@ export class BsDownloaderService{
this.progressBarService.hide(true);
this.resetDownload();
res.success && this.notificationService.notifySuccess({title: `notifications.bs-download.success.titles.${isVerification ? "verification-finished" : "download-success"}`, duration: 3000});
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}); }
return res;
}
+1
View File
@@ -51,6 +51,7 @@ export class I18nService {
}
public translate(translationKey: string, args?: Record<string, string>): string{
console.log(translationKey);
let translated = this.cache.get(translationKey);
if(!translated){
translated = getProperty(this.dictionary, translationKey);