Skip to content

Commit

Permalink
CU-86a63drvf - NEON3 - Investigate why auto update keeps downloading …
Browse files Browse the repository at this point in the history
…forever
  • Loading branch information
dustr94 committed Jan 6, 2025
1 parent 417eef7 commit b662e97
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/main/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,31 @@ import { autoUpdater } from 'electron-updater'

export function registerUpdaterHandler() {
autoUpdater.on('update-downloaded', () => {
mainApi.send('updateCompleted')
})

autoUpdater.on('update-cancelled', () => {
const browserWindow = BrowserWindow.getAllWindows()[0]
if (!browserWindow) return
browserWindow.webContents.send('log', 'update-cancelled')
})

autoUpdater.on('login', () => {
const browserWindow = BrowserWindow.getAllWindows()[0]
if (!browserWindow) return
browserWindow.webContents.send('log', 'login')
})

autoUpdater.on('update-not-available', () => {
const browserWindow = BrowserWindow.getAllWindows()[0]
if (!browserWindow) return
browserWindow.webContents.send('log', 'update-not-available')
})

autoUpdater.on('error', error => {
const browserWindow = BrowserWindow.getAllWindows()[0]
if (!browserWindow) return
browserWindow.webContents.send('updateCompleted')
browserWindow.webContents.send('log', 'Ërror: ' + error.message)
})

mainApi.listenAsync('checkForUpdates', async () => {
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/src/hooks/useBeforeLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ const useOverTheAirUpdate = () => {
window.api.sendAsync('quitAndInstall')
})

const removeLogListener = window.electron.ipcRenderer.on('log', (_event, message) => {
console.log(message)
})

window.api.sendAsync('checkForUpdates').then(hasUpdates => {
if (!hasUpdates) return
ToastHelper.loading({ message: t('downloading'), id: 'auto-update-downloading' })
})

return () => {
removeLogListener()
removeUpdateCompletedListener()
}
}, [dispatch, t])
Expand Down

0 comments on commit b662e97

Please sign in to comment.