Skip to content

Commit

Permalink
Merge branch 'develop' into 2602-move-id-model-to-backend
Browse files Browse the repository at this point in the history
  • Loading branch information
adrastaea authored Oct 25, 2024
2 parents 0001aab + 2f1f448 commit 19e0f22
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/desktop/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,19 @@ const isNetworkError = (errorObject: { message: string }) => {
)
}

export const checkForUpdate = async (win: BrowserWindow) => {
export const checkForUpdate = async () => {
try {
await autoUpdater.checkForUpdates()
} catch (error) {
if (isNetworkError(error)) {
logger.error('Network Error')
logger.warn(`updater: ${error.message}`)
} else {
logger.error('Unknown Error')
logger.error(error == null ? 'unknown' : (error.stack || error).toString())
logger.error(error)
}
}
}

const setupUpdater = async () => {
autoUpdater.on('checking-for-update', () => {
logger.info('updater: checking-for-update')
})
Expand All @@ -285,7 +287,9 @@ export const checkForUpdate = async (win: BrowserWindow) => {
})
autoUpdater.on('update-downloaded', () => {
logger.info('updater: update-downloaded')
win.webContents.send('newUpdateAvailable')
if (isBrowserWindow(mainWindow)) {
mainWindow.webContents.send('newUpdateAvailable')
}
})
autoUpdater.on('before-quit-for-update', () => {
logger.info('updater: before-quit-for-update')
Expand Down Expand Up @@ -505,12 +509,10 @@ app.on('ready', async () => {
}
}

await checkForUpdate(mainWindow)
await setupUpdater()
await checkForUpdate()
setInterval(async () => {
if (!isBrowserWindow(mainWindow)) {
throw new Error(`mainWindow is on unexpected type ${mainWindow}`)
}
await checkForUpdate(mainWindow)
await checkForUpdate()
}, updaterInterval)
})

Expand Down

0 comments on commit 19e0f22

Please sign in to comment.