diff --git a/src/main/window/attach-main-window-services.ts b/src/main/window/attach-main-window-services.ts index ce5ae82e8fd..916000c59d3 100644 --- a/src/main/window/attach-main-window-services.ts +++ b/src/main/window/attach-main-window-services.ts @@ -5,7 +5,7 @@ import { registerRepoHandlers } from '../ipc/repos' import { registerWorktreeHandlers } from '../ipc/worktrees' import { registerPtyHandlers } from '../ipc/pty' import { - checkForUpdates, + checkForUpdatesFromMenu, downloadUpdate, getUpdateStatus, quitAndInstall, @@ -57,7 +57,7 @@ export function registerUpdaterHandlers(): void { ipcMain.handle('updater:getStatus', () => getUpdateStatus()) ipcMain.handle('updater:getVersion', () => app.getVersion()) - ipcMain.handle('updater:check', () => checkForUpdates()) + ipcMain.handle('updater:check', () => checkForUpdatesFromMenu()) ipcMain.handle('updater:download', () => downloadUpdate()) ipcMain.handle('updater:quitAndInstall', () => quitAndInstall()) } diff --git a/src/renderer/src/hooks/useIpcEvents.ts b/src/renderer/src/hooks/useIpcEvents.ts index fd61a183b4b..6ab765c039c 100644 --- a/src/renderer/src/hooks/useIpcEvents.ts +++ b/src/renderer/src/hooks/useIpcEvents.ts @@ -35,6 +35,7 @@ export function useIpcEvents(): void { let checkingToastId: string | number | undefined let availableToastId: string | number | undefined + const downloadToastId = 'update-download-progress' unsubs.push( window.api.updater.onStatus((raw) => { const status = raw as UpdateStatus @@ -65,11 +66,16 @@ export function useIpcEvents(): void { toast.dismiss(availableToastId) availableToastId = undefined } + toast.loading(`Downloading v${status.version}… ${status.percent}%`, { + id: downloadToastId, + duration: Infinity + }) } else if (status.state === 'downloaded') { if (availableToastId) { toast.dismiss(availableToastId) availableToastId = undefined } + toast.dismiss(downloadToastId) toast.success(`Version ${status.version} is ready to install.`, { duration: Infinity, action: { @@ -77,12 +83,15 @@ export function useIpcEvents(): void { onClick: () => window.api.updater.quitAndInstall() } }) - } else if (status.state === 'error' && 'userInitiated' in status && status.userInitiated) { - toast.error('Could not check for updates.', { - description: status.message, - id: checkingToastId - }) - checkingToastId = undefined + } else if (status.state === 'error') { + toast.dismiss(downloadToastId) + if ('userInitiated' in status && status.userInitiated) { + toast.error('Could not check for updates.', { + description: status.message, + id: checkingToastId + }) + checkingToastId = undefined + } } }) )