fix: update notification spam

This commit is contained in:
RockinChaos 2024-08-06 17:47:26 -07:00
parent b0cf8360a8
commit 78191be705

View file

@ -2,16 +2,17 @@ import log from 'electron-log'
import { autoUpdater } from 'electron-updater'
import { ipcMain } from 'electron'
let hasUpdate = false
log.initialize({ spyRendererConsole: true })
log.transports.file.level = 'info'
autoUpdater.logger = log
ipcMain.on('update', () => {
autoUpdater.checkForUpdatesAndNotify()
if (!hasUpdate) autoUpdater.checkForUpdatesAndNotify()
})
autoUpdater.checkForUpdatesAndNotify()
export default class Updater {
hasUpdate = false
/**
* @param {import('electron').BrowserWindow} window
*/
@ -20,21 +21,21 @@ export default class Updater {
window.webContents.send('update-available', true)
})
autoUpdater.on('update-downloaded', () => {
this.hasUpdate = true
hasUpdate = true
window.webContents.send('update-downloaded', true)
})
ipcMain.on('quit-and-install', () => {
if (this.hasUpdate) {
if (hasUpdate) {
autoUpdater.quitAndInstall()
this.hasUpdate = false
hasUpdate = false
}
})
}
install () {
if (this.hasUpdate) {
if (hasUpdate) {
autoUpdater.quitAndInstall()
this.hasUpdate = false
hasUpdate = false
return true
}
}