fix(update): non-blocking desktop update with progress bar (1.0.7)
Release / Create release (push) Successful in 13s
CI / Format and clippy (push) Successful in 28s
CI / Tests (Linux) (push) Successful in 29s
CI / Dependency audit (push) Successful in 14s
Release / CLI (linux-aarch64) (push) Successful in 53s
Release / CLI (linux-x86_64) (push) Successful in 1m22s
CI / Check desktop app (Linux) (push) Successful in 1m19s
Release / Desktop app (linux-aarch64) (push) Successful in 4m27s
Release / Desktop app (linux-x86_64) (push) Successful in 4m58s
Release / Desktop app (windows) (push) Successful in 3m27s
Release / Create release (push) Successful in 13s
CI / Format and clippy (push) Successful in 28s
CI / Tests (Linux) (push) Successful in 29s
CI / Dependency audit (push) Successful in 14s
Release / CLI (linux-aarch64) (push) Successful in 53s
Release / CLI (linux-x86_64) (push) Successful in 1m22s
CI / Check desktop app (Linux) (push) Successful in 1m19s
Release / Desktop app (linux-aarch64) (push) Successful in 4m27s
Release / Desktop app (linux-x86_64) (push) Successful in 4m58s
Release / Desktop app (windows) (push) Successful in 3m27s
Update commands ran on the UI thread and froze the window; they now run in the background, with a real download percentage bar. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fd7435cc68
commit
1bbb5f934c
12 files changed
+104
-22
No files matched your search
+6
-1
@@ -116,7 +116,7 @@ code, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
|
||||
.iface-pick .pill { align-self: flex-start; }
|
||||
|
||||
.side-foot { margin-top: auto; padding: 14px 4px 4px; font-size: 11.5px; color: var(--text-3); display: grid; gap: 8px; }
|
||||
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
||||
.foot-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
|
||||
.side-foot button { background: transparent; border: 0; color: var(--text-3); cursor: pointer; }
|
||||
.side-foot .foot-row > button:not(.icon-btn) { text-decoration: underline; text-underline-offset: 2px; }
|
||||
.side-foot button:hover { color: var(--text-2); }
|
||||
@@ -457,3 +457,8 @@ dialog menu { display: flex; gap: 10px; justify-content: flex-end; padding: 0; m
|
||||
.report-dlg { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
|
||||
.report-view { padding: 8px; }
|
||||
}
|
||||
|
||||
.upd-bar { flex-basis: 100%; height: 6px; border-radius: 99px; margin-top: 8px; overflow: hidden; background: color-mix(in srgb, currentColor 12%, transparent); }
|
||||
.upd-bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent, currentColor); transition: width .3s ease; }
|
||||
.upd-bar.indet > i { animation: upd-slide 1.2s infinite ease-in-out; }
|
||||
@keyframes upd-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
|
||||
+19
-1
@@ -376,19 +376,36 @@ els.btnScan.addEventListener('click', async () => {
|
||||
let updateStatus = null;
|
||||
let updateInProgress = false;
|
||||
|
||||
// Progress bar under the update button (indeterminate until a percentage arrives).
|
||||
function setUpdBar(pct) {
|
||||
const row = els.btnUpdate.parentElement;
|
||||
let bar = row.querySelector('.upd-bar');
|
||||
if (!bar) {
|
||||
bar = document.createElement('div');
|
||||
bar.className = 'upd-bar';
|
||||
bar.innerHTML = '<i></i>';
|
||||
row.appendChild(bar);
|
||||
}
|
||||
bar.classList.toggle('indet', pct == null);
|
||||
bar.firstChild.style.width = pct == null ? '35%' : `${pct}%`;
|
||||
}
|
||||
|
||||
els.btnUpdate.addEventListener('click', async () => {
|
||||
if (updateInProgress) return;
|
||||
if (updateStatus?.update_available) {
|
||||
updateInProgress = true;
|
||||
els.btnUpdate.disabled = true;
|
||||
els.btnUpdate.textContent = 'baixando…';
|
||||
setUpdBar(null);
|
||||
|
||||
let unlisten = null;
|
||||
if (tauri?.event?.listen) {
|
||||
try {
|
||||
unlisten = await tauri.event.listen('update-progress', (event) => {
|
||||
const phase = event.payload?.phase;
|
||||
if (phase === 'downloading') els.btnUpdate.textContent = 'baixando…';
|
||||
const pct = event.payload?.percent;
|
||||
setUpdBar(pct);
|
||||
if (phase === 'downloading') els.btnUpdate.textContent = pct != null ? `baixando… ${pct}%` : 'baixando…';
|
||||
else if (phase === 'verifying') els.btnUpdate.textContent = 'verificando…';
|
||||
else if (phase === 'installing') els.btnUpdate.textContent = 'instalando…';
|
||||
else if (phase === 'restarting') els.btnUpdate.textContent = 'reiniciando…';
|
||||
@@ -401,6 +418,7 @@ els.btnUpdate.addEventListener('click', async () => {
|
||||
els.btnUpdate.textContent = 'já atualizado';
|
||||
} catch (err) {
|
||||
updateInProgress = false;
|
||||
els.btnUpdate.parentElement.querySelector('.upd-bar')?.remove();
|
||||
els.btnUpdate.disabled = false;
|
||||
els.btnUpdate.textContent = `atualizar para ${updateStatus.latest_version}`;
|
||||
alert('Falha na atualização: ' + (err?.message || err));
|
||||
|
||||
@@ -570,4 +570,5 @@ export const EN = {
|
||||
'a captura em {n} não está ativa': 'capture on {n} is not active',
|
||||
'{n} não está disponível; o reaver integrado não pôde ser extraído':
|
||||
'{n} is not available; the bundled reaver could not be extracted',
|
||||
'baixando… {n}%': 'downloading… {n}%',
|
||||
};
|
||||
Reference in new issue
Block a user