fix(updater): unify install lifecycle across startup and dialog paths

This commit is contained in:
Tunglies
2026-11-26 23:29:46 +08:00
parent 8fe3cc1fe3
commit 2905b0a194
3 changed files with 46 additions and 22 deletions
@@ -267,6 +267,9 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
})
const { downloaded, total } = download
// Install cannot be cancelled; only the download can.
const [installing, setInstalling] = useState(false)
const progress = total <= 0 ? 0 : Math.min((downloaded / total) * 100, 100)
useImperativeHandle(ref, () => ({
@@ -333,6 +336,8 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
...prev,
total: prev.total || prev.downloaded,
}))
} else if (event.event === 'Installing') {
setInstalling(true)
}
}
@@ -366,6 +371,7 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
} finally {
setUpdateState(false)
setDownload({ downloaded: 0, total: 0 })
setInstalling(false)
}
})
@@ -419,6 +425,7 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
}}
okBtn={t('settings.modals.update.actions.update')}
cancelBtn={t('shared.actions.cancel')}
disableCancel={installing}
onClose={() => setOpen(false)}
onCancel={() => {
if (updateState) {
@@ -560,7 +567,7 @@ export function UpdateViewer({ ref }: { ref?: Ref<UpdateViewerRef> }) {
</Box>
{updateState && (
<LinearProgress
variant={total > 0 ? 'determinate' : 'indeterminate'}
variant={total > 0 && !installing ? 'determinate' : 'indeterminate'}
value={progress}
sx={{ mt: 1 }}
/>
+14 -3
View File
@@ -260,10 +260,16 @@ export type DnsOverrideOutcome =
| { status: 'applied' }
| { status: 'confirmation_required'; source: string }
/** Same wire shape as the updater plugin's JS `DownloadEvent`. */
/**
* Same wire shape as the updater plugin's JS `DownloadEvent`, plus `Installing` when the
* install starts.
*/
export type DownloadEvent = DownloadEvent_Serialize | DownloadEvent_Deserialize
/** Same wire shape as the updater plugin's JS `DownloadEvent`. */
/**
* Same wire shape as the updater plugin's JS `DownloadEvent`, plus `Installing` when the
* install starts.
*/
export type DownloadEvent_Deserialize =
| {
event: 'Started'
@@ -278,8 +284,12 @@ export type DownloadEvent_Deserialize =
}
}
| { event: 'Finished' }
| { event: 'Installing' }
/** Same wire shape as the updater plugin's JS `DownloadEvent`. */
/**
* Same wire shape as the updater plugin's JS `DownloadEvent`, plus `Installing` when the
* install starts.
*/
export type DownloadEvent_Serialize =
| {
event: 'Started'
@@ -294,6 +304,7 @@ export type DownloadEvent_Serialize =
}
}
| { event: 'Finished' }
| { event: 'Installing' }
/** Operation associated with a pending failure. */
export type FailedOperation =