mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-23 19:01:02 +00:00
feat: disabling button when installing
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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`,
|
||||
});
|
||||
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user