mirror of
https://github.com/NoCrypt/migu.git
synced 2026-05-14 14:00:48 +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 { autoUpdater } from 'electron-updater'
|
||||||
import { ipcMain } from 'electron'
|
import { ipcMain } from 'electron'
|
||||||
|
|
||||||
|
let hasUpdate = false
|
||||||
|
|
||||||
log.initialize({ spyRendererConsole: true })
|
log.initialize({ spyRendererConsole: true })
|
||||||
log.transports.file.level = 'info'
|
log.transports.file.level = 'info'
|
||||||
autoUpdater.logger = log
|
autoUpdater.logger = log
|
||||||
ipcMain.on('update', () => {
|
ipcMain.on('update', () => {
|
||||||
autoUpdater.checkForUpdatesAndNotify()
|
if (!hasUpdate) autoUpdater.checkForUpdatesAndNotify()
|
||||||
})
|
})
|
||||||
|
|
||||||
autoUpdater.checkForUpdatesAndNotify()
|
autoUpdater.checkForUpdatesAndNotify()
|
||||||
export default class Updater {
|
export default class Updater {
|
||||||
hasUpdate = false
|
|
||||||
/**
|
/**
|
||||||
* @param {import('electron').BrowserWindow} window
|
* @param {import('electron').BrowserWindow} window
|
||||||
*/
|
*/
|
||||||
|
|
@ -20,21 +21,21 @@ export default class Updater {
|
||||||
window.webContents.send('update-available', true)
|
window.webContents.send('update-available', true)
|
||||||
})
|
})
|
||||||
autoUpdater.on('update-downloaded', () => {
|
autoUpdater.on('update-downloaded', () => {
|
||||||
this.hasUpdate = true
|
hasUpdate = true
|
||||||
window.webContents.send('update-downloaded', true)
|
window.webContents.send('update-downloaded', true)
|
||||||
})
|
})
|
||||||
ipcMain.on('quit-and-install', () => {
|
ipcMain.on('quit-and-install', () => {
|
||||||
if (this.hasUpdate) {
|
if (hasUpdate) {
|
||||||
autoUpdater.quitAndInstall()
|
autoUpdater.quitAndInstall()
|
||||||
this.hasUpdate = false
|
hasUpdate = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
install () {
|
install () {
|
||||||
if (this.hasUpdate) {
|
if (hasUpdate) {
|
||||||
autoUpdater.quitAndInstall()
|
autoUpdater.quitAndInstall()
|
||||||
this.hasUpdate = false
|
hasUpdate = false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue