feat: disabling button when installing

This commit is contained in:
Chubby Granny Chaser
2025-04-06 22:48:12 +01:00
parent 04f061afa3
commit 21535d8acc
6 changed files with 32 additions and 7 deletions

View File

@@ -353,7 +353,8 @@
"enable_auto_install": "Download updates automatically",
"common_redist": "Common redistributables",
"common_redist_description": "Common redistributables are required to run some games. Installing them is recommended to avoid issues.",
"install_common_redist": "Install"
"install_common_redist": "Install",
"installing_common_redist": "Installing…"
},
"notifications": {
"download_complete": "Download complete",

View File

@@ -340,7 +340,8 @@
"enable_auto_install": "Baixar atualizações automaticamente",
"common_redist": "Componentes recomendados",
"common_redist_description": "Componentes recomendados são necessários para executar alguns jogos. A instalação deles é recomendada para evitar problemas.",
"install_common_redist": "Instalar"
"install_common_redist": "Instalar",
"installing_common_redist": "Instalando…"
},
"notifications": {
"download_complete": "Download concluído",

View File

@@ -23,7 +23,7 @@ export const db = new Dexie("Hydra");
db.version(9).stores({
repacks: `++id, title, uris, fileSize, uploadDate, downloadSourceId, repacker, objectIds, createdAt, updatedAt`,
downloadSources: `++id, url, name, etag, objectIds, downloadCount, status, fingerprint, createdAt, updatedAt`,
downloadSources: `++id, &url, name, etag, objectIds, downloadCount, status, fingerprint, createdAt, updatedAt`,
howLongToBeatEntries: `++id, categories, [shop+objectId], createdAt, updatedAt`,
});

View File

@@ -29,6 +29,7 @@ export function SettingsGeneral() {
);
const [canInstallCommonRedist, setCanInstallCommonRedist] = useState(false);
const [installingCommonRedist, setInstallingCommonRedist] = useState(false);
const [form, setForm] = useState({
downloadsPath: "",
@@ -133,6 +134,27 @@ export function SettingsGeneral() {
}
};
useEffect(() => {
const unlisten = window.electron.onCommonRedistProgress(
({ log, complete }) => {
if (log === "Installation timed out" || complete) {
setInstallingCommonRedist(false);
}
}
);
return () => unlisten();
}, []);
const handleInstallCommonRedist = async () => {
setInstallingCommonRedist(true);
try {
await window.electron.installCommonRedist();
} finally {
setInstallingCommonRedist(false);
}
};
return (
<div className="settings-general">
<TextField
@@ -210,12 +232,14 @@ export function SettingsGeneral() {
</p>
<Button
onClick={() => window.electron.installCommonRedist()}
onClick={handleInstallCommonRedist}
className="settings-general__common-redist-button"
disabled={!canInstallCommonRedist}
>
<DesktopDownloadIcon />
{t("install_common_redist")}
{installingCommonRedist
? t("installing_common_redist")
: t("install_common_redist")}
</Button>
</div>
);