diff --git a/public/script/autoUpdate.js b/public/script/autoUpdate.js index f8fbcad..0cced57 100644 --- a/public/script/autoUpdate.js +++ b/public/script/autoUpdate.js @@ -45,13 +45,32 @@ async function initUpdateUI() { return; } - btn.onclick = () => { - window.electronAPI.downloadUpdate(); + const initialButtonText = btn.textContent; + const initialIconText = icon.textContent; + const initialTitleText = title.textContent; + const initialSubText = sub.textContent; + + btn.onclick = async () => { + btn.disabled = true; btn.textContent = "Downloading..."; icon.textContent = "download"; title.textContent = "Downloading update"; progressWrap.style.display = "flex"; + + 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 = ""; + } }; window.electronAPI.onDownloadProgress((progress) => {