mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-07-08 19:15:09 +00:00
Improved update check fail case
This commit is contained in:
@@ -14,7 +14,15 @@ let updateAvailable = false
|
||||
/**
|
||||
* Checks for updates when the program is launched.
|
||||
*/
|
||||
class UpdateChecker {
|
||||
class UpdateChecker implements IPCEmitHandler<'retry-update'> {
|
||||
event: 'retry-update' = 'retry-update'
|
||||
|
||||
/**
|
||||
* Check for an update.
|
||||
*/
|
||||
handler() {
|
||||
this.checkForUpdates()
|
||||
}
|
||||
|
||||
constructor() {
|
||||
autoUpdater.autoDownload = false
|
||||
@@ -23,11 +31,15 @@ class UpdateChecker {
|
||||
}
|
||||
|
||||
checkForUpdates() {
|
||||
autoUpdater.checkForUpdates()
|
||||
autoUpdater.checkForUpdates().catch(reason => {
|
||||
updateAvailable = null
|
||||
emitIPCEvent('update-error', reason)
|
||||
})
|
||||
}
|
||||
|
||||
private registerUpdaterListeners() {
|
||||
autoUpdater.on('error', (err: Error) => {
|
||||
updateAvailable = null
|
||||
emitIPCEvent('update-error', err)
|
||||
})
|
||||
|
||||
@@ -35,6 +47,11 @@ class UpdateChecker {
|
||||
updateAvailable = true
|
||||
emitIPCEvent('update-available', info)
|
||||
})
|
||||
|
||||
autoUpdater.on('update-not-available', (info: UpdateInfo) => {
|
||||
updateAvailable = false
|
||||
emitIPCEvent('update-available', null)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Settings } from './Settings'
|
||||
import { batchSongDetailsHandler } from '../ipc/browse/BatchSongDetailsHandler.ipc'
|
||||
import { getSettingsHandler, setSettingsHandler } from '../ipc/SettingsHandler.ipc'
|
||||
import { googleLoginHandler, getAuthStatusHandler, googleLogoutHandler } from '../ipc/google/GoogleLoginHandler.ipc'
|
||||
import { UpdateProgress, getCurrentVersionHandler, downloadUpdateHandler, quitAndInstallHandler, getUpdateAvailableHandler } from '../ipc/UpdateHandler.ipc'
|
||||
import { updateChecker, UpdateProgress, getCurrentVersionHandler, downloadUpdateHandler, quitAndInstallHandler, getUpdateAvailableHandler } from '../ipc/UpdateHandler.ipc'
|
||||
import { UpdateInfo } from 'electron-updater'
|
||||
import { openURLHandler } from '../ipc/OpenURLHandler.ipc'
|
||||
|
||||
@@ -96,6 +96,7 @@ export function getIPCEmitHandlers(): IPCEmitHandler<keyof IPCEmitEvents>[] {
|
||||
downloadHandler,
|
||||
setSettingsHandler,
|
||||
downloadUpdateHandler,
|
||||
updateChecker,
|
||||
quitAndInstallHandler,
|
||||
openURLHandler
|
||||
]
|
||||
@@ -115,6 +116,7 @@ export type IPCEmitEvents = {
|
||||
'update-progress': UpdateProgress
|
||||
'update-downloaded': undefined
|
||||
'download-update': undefined
|
||||
'retry-update': undefined
|
||||
'quit-and-install': undefined
|
||||
'open-url': string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user