mirror of
https://github.com/NoCrypt/migu.git
synced 2026-01-11 20:10:22 +00:00
fix: update notification spam
This commit is contained in:
parent
b0cf8360a8
commit
78191be705
1 changed files with 8 additions and 7 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue