From 0a597acd26e99a9f305630ee1eb83467fbc414f8 Mon Sep 17 00:00:00 2001
From: Hydra
Date: Sat, 4 May 2024 18:25:19 +0100
Subject: [PATCH] fix: fixing translations and typescript renderer errors
---
src/locales/es/translation.json | 40 ++++++++++++-----
.../events/library/add-game-to-library.ts | 2 +-
src/main/events/misc/show-open-dialog.ts | 6 ++-
src/main/index.ts | 2 +-
src/main/services/steam-250.ts | 3 +-
src/main/services/window-manager.ts | 12 +++---
src/renderer/src/declaration.d.ts | 2 +-
src/renderer/src/helpers.ts | 2 +
.../src/pages/downloads/downloads.tsx | 13 ++++--
.../game-details/hero/hero-panel-actions.tsx | 43 +++++++++++--------
.../pages/game-details/hero/hero-panel.tsx | 10 ++---
.../src/pages/game-details/repacks-modal.tsx | 4 +-
12 files changed, 90 insertions(+), 49 deletions(-)
diff --git a/src/locales/es/translation.json b/src/locales/es/translation.json
index 8f36c12f..1a8f5d48 100644
--- a/src/locales/es/translation.json
+++ b/src/locales/es/translation.json
@@ -15,9 +15,12 @@
"checking_files": "{{title}} ({{percentage}} - Analizando archivos…)",
"paused": "{{title}} (Pausado)",
"downloading": "{{title}} ({{percentage}} - Descargando…)",
- "filter": "Filtrar biblioteca",
+ "filter": "Buscar en la biblioteca",
+ "follow_us": "Síguenos",
"home": "Inicio",
- "follow_us": "Síguenos"
+ "discord": "Únete a nuestro Discord",
+ "x": "Síguenos en X",
+ "github": "Contribuye en GitHub"
},
"header": {
"search": "Buscar",
@@ -45,7 +48,7 @@
"remove": "Eliminar",
"remove_from_list": "Quitar",
"space_left_on_disk": "{{space}} restantes en el disco",
- "eta": "Finalizando {{eta}}",
+ "eta": "Finalizando en {{eta}}",
"downloading_metadata": "Descargando metadatos…",
"checking_files": "Analizando archivos…",
"filter": "Filtrar repacks",
@@ -55,14 +58,12 @@
"no_minimum_requirements": "Sin requisitos mínimos para {{title}}",
"no_recommended_requirements": "{{title}} no tiene requisitos recomendados",
"paused_progress": "{{progress}} (Pausado)",
- "release_date": "Fecha de lanzamiento {{date}}",
- "publisher": "Publicado por {{publisher}}",
+ "release_date": "Fecha de lanzamiento: {{date}}",
+ "publisher": "Publicado por: {{publisher}}",
"copy_link_to_clipboard": "Copiar enlace",
"copied_link_to_clipboard": "Enlace copiado",
"hours": "horas",
"minutes": "minutos",
- "amount_hours": "{{amount}} horas",
- "amount_minutes": "{{amount}} minutos",
"accuracy": "{{accuracy}}% precisión",
"add_to_library": "Agregar a la biblioteca",
"remove_from_library": "Eliminar de la biblioteca",
@@ -75,7 +76,21 @@
"close": "Cerrar",
"deleting": "Eliminando instalador…",
"playing_now": "Jugando ahora",
- "last_time_played": "Jugado por última vez {{period}}"
+ "last_time_played": "Jugado por última vez {{period}}",
+ "got_it": "Entendido",
+ "change": "Cambiar",
+ "repacks_modal_description": "Selecciona el repack que quieres descargar",
+ "downloads_path": "Ruta de descarga",
+ "select_folder_hint": "Para cambiar la carpeta predeterminada, accede a",
+ "settings": "Ajustes",
+ "download_now": "Descargar ahora",
+ "installation_instructions": "Instrucciones de instalación",
+ "installation_instructions_description": "Se requieren de pasos adicionales para instalar este juego",
+ "online_fix_instruction": "Los juegos de OnlineFix requieren una contraseña para ser extraídos. Cuando se requiera, usa la siguiente contraseña:",
+ "dodi_installation_instruction": "Cuando abras el instalador de DODI, presiona la tecla hacia arriba del teclado <0 /> para iniciar el proceso de instalación:",
+ "dont_show_it_again": "No mostrar de nuevo",
+ "copy_to_clipboard": "Copiar",
+ "copied_to_clipboard": "Copiado"
},
"activation": {
"title": "Activar Hydra",
@@ -88,7 +103,7 @@
"downloads": {
"resume": "Resumir",
"pause": "Pausa",
- "eta": "Finalizando {{eta}}",
+ "eta": "Finalizando en {{eta}}",
"paused": "En Pausa",
"verifying": "Verificando…",
"completed_at": "Completado el {{date}}",
@@ -103,8 +118,8 @@
"starting_download": "Iniciando descarga…",
"remove_from_list": "Eliminar",
"delete": "Eliminar instalador",
- "delete_modal_description": "Esto eliminará todos los archivos de instalación de su computadora.",
- "delete_modal_title": "¿Está seguro?",
+ "delete_modal_description": "Esto eliminará todos los archivos de instalación de tu computadora.",
+ "delete_modal_title": "¿Estás seguro?",
"deleting": "Eliminando instalador…",
"install": "Instalar"
},
@@ -136,6 +151,9 @@
"description": "Los ejecutables de Wine o Lutris no se encontraron en su sistema",
"instructions": "Comprueba como instalar de forma correcta uno de los dos en tu distro de Linux para ejecutar el juego con normalidad"
},
+ "modal": {
+ "close": "Botón de cierre"
+ },
"catalogue": {
"next_page": "Siguiente página",
"previous_page": "Pagina anterior"
diff --git a/src/main/events/library/add-game-to-library.ts b/src/main/events/library/add-game-to-library.ts
index 4089678f..49f42d5f 100644
--- a/src/main/events/library/add-game-to-library.ts
+++ b/src/main/events/library/add-game-to-library.ts
@@ -11,7 +11,7 @@ const addGameToLibrary = async (
objectID: string,
title: string,
gameShop: GameShop,
- executablePath: string
+ executablePath: string | null
) => {
const game = await gameRepository.findOne({
where: {
diff --git a/src/main/events/misc/show-open-dialog.ts b/src/main/events/misc/show-open-dialog.ts
index 123a47d6..baa6a016 100644
--- a/src/main/events/misc/show-open-dialog.ts
+++ b/src/main/events/misc/show-open-dialog.ts
@@ -5,7 +5,11 @@ import { registerEvent } from "../register-event";
const showOpenDialog = async (
_event: Electron.IpcMainInvokeEvent,
options: Electron.OpenDialogOptions
-) => dialog.showOpenDialog(WindowManager.mainWindow, options);
+) => {
+ if (WindowManager.mainWindow) {
+ dialog.showOpenDialog(WindowManager.mainWindow, options);
+ }
+};
registerEvent(showOpenDialog, {
name: "showOpenDialog",
diff --git a/src/main/index.ts b/src/main/index.ts
index 4d953022..54f0d5b8 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -85,7 +85,7 @@ app.on("second-instance", (_event, commandLine) => {
WindowManager.createMainWindow();
}
- const [, path] = commandLine.pop().split("://");
+ const [, path] = commandLine.pop()?.split("://") ?? [];
if (path) WindowManager.redirect(path);
});
diff --git a/src/main/services/steam-250.ts b/src/main/services/steam-250.ts
index 0ece8ae5..db505b47 100644
--- a/src/main/services/steam-250.ts
+++ b/src/main/services/steam-250.ts
@@ -41,7 +41,8 @@ export const getSteam250List = async () => {
).flat();
const gamesMap: Map = gamesList.reduce((map, item) => {
- map.set(item.objectID, item);
+ if (item) map.set(item.objectID, item);
+
return map;
}, new Map());
diff --git a/src/main/services/window-manager.ts b/src/main/services/window-manager.ts
index 95a73605..6b46a77a 100644
--- a/src/main/services/window-manager.ts
+++ b/src/main/services/window-manager.ts
@@ -1,4 +1,4 @@
-import { BrowserWindow, Menu, Notification, Tray, app } from "electron";
+import { BrowserWindow, Menu, Tray, app } from "electron";
import { is } from "@electron-toolkit/utils";
import { t } from "i18next";
import path from "node:path";
@@ -50,15 +50,15 @@ export class WindowManager {
this.loadURL();
this.mainWindow.removeMenu();
- const userPreferences = await userPreferencesRepository.findOne({
- where: { id: 1 },
- });
-
this.mainWindow.on("ready-to-show", () => {
if (!app.isPackaged) WindowManager.mainWindow?.webContents.openDevTools();
});
- this.mainWindow.on("close", () => {
+ this.mainWindow.on("close", async () => {
+ const userPreferences = await userPreferencesRepository.findOne({
+ where: { id: 1 },
+ });
+
if (userPreferences?.preferQuitInsteadOfHiding) {
app.quit();
}
diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts
index b3aa2d70..5ea29ca5 100644
--- a/src/renderer/src/declaration.d.ts
+++ b/src/renderer/src/declaration.d.ts
@@ -56,7 +56,7 @@ declare global {
objectID: string,
title: string,
shop: GameShop,
- executablePath: string
+ executablePath: string | null
) => Promise;
getLibrary: () => Promise;
getRepackersFriendlyNames: () => Promise>;
diff --git a/src/renderer/src/helpers.ts b/src/renderer/src/helpers.ts
index 89da2bca..6548938f 100644
--- a/src/renderer/src/helpers.ts
+++ b/src/renderer/src/helpers.ts
@@ -24,5 +24,7 @@ export const getSteamLanguage = (language: string) => {
if (language.startsWith("ru")) return "russian";
if (language.startsWith("it")) return "italian";
if (language.startsWith("hu")) return "hungarian";
+ if (language.startsWith("pl")) return "polish";
+
return "english";
};
diff --git a/src/renderer/src/pages/downloads/downloads.tsx b/src/renderer/src/pages/downloads/downloads.tsx
index 7dfa15d2..0f625490 100644
--- a/src/renderer/src/pages/downloads/downloads.tsx
+++ b/src/renderer/src/pages/downloads/downloads.tsx
@@ -103,6 +103,7 @@ export function Downloads() {
>
);
}
+
if (game?.status === "cancelled") return {t("cancelled")}
;
if (game?.status === "downloading_metadata")
return {t("starting_download")}
;
@@ -115,6 +116,8 @@ export function Downloads() {
>
);
}
+
+ return null;
};
const openDeleteModal = (gameId: number) => {
@@ -210,6 +213,12 @@ export function Downloads() {
);
};
+ const handleDeleteGame = () => {
+ if (gameToBeDeleted.current) {
+ deleteGame(gameToBeDeleted.current).then(updateLibrary);
+ }
+ };
+
return (
setShowDeleteModal(false)}
- deleteGame={() =>
- deleteGame(gameToBeDeleted.current).then(updateLibrary)
- }
+ deleteGame={handleDeleteGame}
/>
diff --git a/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx b/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx
index 4bc6df17..4c4b9a5a 100644
--- a/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx
+++ b/src/renderer/src/pages/game-details/hero/hero-panel-actions.tsx
@@ -68,7 +68,7 @@ export function HeroPanelActions({
try {
if (game) {
await removeGameFromLibrary(game.id);
- } else {
+ } else if (gameDetails) {
const gameExecutablePath = await selectGameExecutable();
await window.electron.addGameToLibrary(
@@ -87,30 +87,37 @@ export function HeroPanelActions({
};
const openGameInstaller = () => {
- window.electron.openGameInstaller(game.id).then((isBinaryInPath) => {
- if (!isBinaryInPath) openBinaryNotFoundModal();
- updateLibrary();
- });
+ if (game) {
+ window.electron.openGameInstaller(game.id).then((isBinaryInPath) => {
+ if (!isBinaryInPath) openBinaryNotFoundModal();
+ updateLibrary();
+ });
+ }
};
const openGame = async () => {
- if (game.executablePath) {
- window.electron.openGame(game.id, game.executablePath);
- return;
- }
+ if (game) {
+ if (game.executablePath) {
+ window.electron.openGame(game.id, game.executablePath);
+ return;
+ }
- if (game?.executablePath) {
- window.electron.openGame(game.id, game.executablePath);
- return;
- }
+ if (game?.executablePath) {
+ window.electron.openGame(game.id, game.executablePath);
+ return;
+ }
- const gameExecutablePath = await selectGameExecutable();
- window.electron.openGame(game.id, gameExecutablePath);
+ const gameExecutablePath = await selectGameExecutable();
+ if (gameExecutablePath)
+ window.electron.openGame(game.id, gameExecutablePath);
+ }
};
- const closeGame = () => window.electron.closeGame(game.id);
+ const closeGame = () => {
+ if (game) window.electron.closeGame(game.id);
+ };
- const deleting = isGameDeleting(game?.id);
+ const deleting = game ? isGameDeleting(game?.id) : false;
const toggleGameOnLibraryButton = (
;
}
- if (isGameDownloading) {
+ if (isGameDownloading && gameDownloading?.status) {
return (
<>
@@ -106,14 +106,14 @@ export function HeroPanel({
{eta && {t("eta", { eta })}}
- {gameDownloading?.status !== "downloading" ? (
+ {gameDownloading.status !== "downloading" ? (
<>
- {t(gameDownloading?.status)}
+ {t(gameDownloading.status)}
{eta && {t("eta", { eta })}}
>
) : (
- {formatBytes(gameDownloading?.bytesDownloaded)} /{" "}
+ {formatBytes(gameDownloading.bytesDownloaded)} /{" "}
{finalDownloadSize}
{numPeers} peers / {numSeeds} seeds
@@ -148,7 +148,7 @@ export function HeroPanel({
<>
{t("play_time", {
- amount: formatPlayTime(game.playTimeInMilliseconds),
+ amount: formatPlayTime(),
})}
diff --git a/src/renderer/src/pages/game-details/repacks-modal.tsx b/src/renderer/src/pages/game-details/repacks-modal.tsx
index caa98d5c..aebcb071 100644
--- a/src/renderer/src/pages/game-details/repacks-modal.tsx
+++ b/src/renderer/src/pages/game-details/repacks-modal.tsx
@@ -89,7 +89,9 @@ export function RepacksModal({
{repack.title}
{repack.fileSize} - {repackersFriendlyNames[repack.repacker]} -{" "}
- {format(repack.uploadDate, "dd/MM/yyyy")}
+ {repack.uploadDate
+ ? format(repack.uploadDate, "dd/MM/yyyy")
+ : ""}
))}