mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-11-13 15:09:20 +01:00
fix(autoUpdate): improve error handling and UI reset during update process
This commit is contained in:
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user