From f8ea4f29d9e5c8a80be21ba093a4bb844ee2a559 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Sun, 6 Apr 2025 22:17:54 +0100 Subject: [PATCH] feat: adding optional common redist install --- src/locales/pt-BR/translation.json | 5 ++++- src/main/services/common-redist-manager.ts | 4 +--- src/preload/index.ts | 4 ++-- src/renderer/src/declaration.d.ts | 2 +- src/renderer/src/pages/settings/settings-general.tsx | 10 ++++++++++ 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/locales/pt-BR/translation.json b/src/locales/pt-BR/translation.json index 2adc0d1d..3cb8fa91 100644 --- a/src/locales/pt-BR/translation.json +++ b/src/locales/pt-BR/translation.json @@ -44,7 +44,10 @@ "downloading_metadata": "Baixando metadados de {{title}}…", "downloading": "Baixando {{title}}… ({{percentage}} concluído) - Conclusão {{eta}} - {{speed}}", "calculating_eta": "Baixando {{title}}… ({{percentage}} concluído) - Calculando tempo restante…", - "checking_files": "Verificando arquivos de {{title}}…" + "checking_files": "Verificando arquivos de {{title}}…", + "installing_common_redist": "{{log}}…", + "installation_complete": "Instalação concluída", + "installation_complete_message": "Componentes recomendados instalados com sucesso" }, "game_details": { "open_download_options": "Ver opções de download", diff --git a/src/main/services/common-redist-manager.ts b/src/main/services/common-redist-manager.ts index cb9753a0..2a08bfab 100644 --- a/src/main/services/common-redist-manager.ts +++ b/src/main/services/common-redist-manager.ts @@ -56,10 +56,8 @@ export class CommonRedistManager { } } - const [_, component] = tail?.split("Installing ") ?? []; - WindowManager.mainWindow?.webContents.send("common-redist-progress", { - component: component, + log: tail, complete: tail?.includes(installationCompleteMessage), }); }); diff --git a/src/preload/index.ts b/src/preload/index.ts index 01b0b9e6..280c0cc4 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -313,11 +313,11 @@ contextBridge.exposeInMainWorld("electron", { }; }, onCommonRedistProgress: ( - cb: (value: { component: string; complete: boolean }) => void + cb: (value: { log: string; complete: boolean }) => void ) => { const listener = ( _event: Electron.IpcRendererEvent, - value: { component: string; complete: boolean } + value: { log: string; complete: boolean } ) => cb(value); ipcRenderer.on("common-redist-progress", listener); return () => ipcRenderer.removeListener("common-redist-progress", listener); diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts index 2fe336ae..791370a2 100644 --- a/src/renderer/src/declaration.d.ts +++ b/src/renderer/src/declaration.d.ts @@ -237,7 +237,7 @@ declare global { canInstallCommonRedist: () => Promise; installCommonRedist: () => Promise; onCommonRedistProgress: ( - cb: (value: { component: string; complete: boolean }) => void + cb: (value: { log: string; complete: boolean }) => void ) => () => Electron.IpcRenderer; platform: NodeJS.Platform; diff --git a/src/renderer/src/pages/settings/settings-general.tsx b/src/renderer/src/pages/settings/settings-general.tsx index 32b70614..dc43e8a1 100644 --- a/src/renderer/src/pages/settings/settings-general.tsx +++ b/src/renderer/src/pages/settings/settings-general.tsx @@ -54,6 +54,12 @@ export function SettingsGeneral() { setCanInstallCommonRedist(canInstall); }); + const interval = setInterval(() => { + window.electron.canInstallCommonRedist().then((canInstall) => { + setCanInstallCommonRedist(canInstall); + }); + }, 1000 * 5); + setLanguageOptions( orderBy( Object.entries(languageResources).map(([language, value]) => { @@ -66,6 +72,10 @@ export function SettingsGeneral() { "asc" ) ); + + return () => { + clearInterval(interval); + }; }, []); useEffect(() => {