fix(autoUpdate): improve error handling and UI reset during update process

This commit is contained in:
MasterAcnolo
2026-09-29 17:20:42 +02:00
parent ac1d74ff23
commit 1937738ab8
3 changed files with 31 additions and 9 deletions

View File

@@ -50,6 +50,23 @@ async function initUpdateUI() {
const initialTitleText = title.textContent;
const initialSubText = sub.textContent;
const resetUI = () => {
btn.disabled = false;
btn.textContent = initialButtonText;
icon.textContent = initialIconText;
title.textContent = initialTitleText;
sub.textContent = initialSubText;
progressWrap.style.display = "none";
progressFill.style.width = "0%";
progressPct.textContent = "0%";
progressEta.textContent = "";
};
window.electronAPI.onUpdateError((err) => {
console.error("Update failed asynchronously:", err);
resetUI();
});
btn.onclick = async () => {
btn.disabled = true;
@@ -61,15 +78,7 @@ async function initUpdateUI() {
try {
await window.electronAPI.downloadUpdate();
} catch {
btn.disabled = false;
btn.textContent = initialButtonText;
icon.textContent = initialIconText;
title.textContent = initialTitleText;
sub.textContent = initialSubText;
progressWrap.style.display = "none";
progressFill.style.width = "0%";
progressPct.textContent = "0%";
progressEta.textContent = "";
resetUI();
}
};