diff --git a/assets/jsons/translations/en.json b/assets/jsons/translations/en.json index 4c07473c..63d2ba44 100644 --- a/assets/jsons/translations/en.json +++ b/assets/jsons/translations/en.json @@ -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.", diff --git a/assets/jsons/translations/es.json b/assets/jsons/translations/es.json index e8032c3b..320f6534 100644 --- a/assets/jsons/translations/es.json +++ b/assets/jsons/translations/es.json @@ -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.", diff --git a/assets/jsons/translations/fr.json b/assets/jsons/translations/fr.json index b75dfa42..6b2df819 100644 --- a/assets/jsons/translations/fr.json +++ b/assets/jsons/translations/fr.json @@ -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.", diff --git a/src/main/services/bs-installer.service.ts b/src/main/services/bs-installer.service.ts index 9c21d91a..8ca720cb 100644 --- a/src/main/services/bs-installer.service.ts +++ b/src/main/services/bs-installer.service.ts @@ -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{ - 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]"; diff --git a/src/renderer/services/bs-downloader.service.ts b/src/renderer/services/bs-downloader.service.ts index 916cb421..a3efacf1 100644 --- a/src/renderer/services/bs-downloader.service.ts +++ b/src/renderer/services/bs-downloader.service.ts @@ -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; } diff --git a/src/renderer/services/i18n.service.ts b/src/renderer/services/i18n.service.ts index 6971d8e3..b5b0353d 100644 --- a/src/renderer/services/i18n.service.ts +++ b/src/renderer/services/i18n.service.ts @@ -51,6 +51,7 @@ export class I18nService { } public translate(translationKey: string, args?: Record): string{ + console.log(translationKey); let translated = this.cache.get(translationKey); if(!translated){ translated = getProperty(this.dictionary, translationKey);