From 6bb9366ec8649edc36bf6df2f0a1928dbce6334d Mon Sep 17 00:00:00 2001 From: Dick Choi Date: Wed, 21 Sep 2016 16:00:18 +0900 Subject: [PATCH] fix update error --- browser/main/StatusBar/index.js | 14 ++++++++++++++ lib/main-app.js | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/browser/main/StatusBar/index.js b/browser/main/StatusBar/index.js index f572e853..c63194cb 100644 --- a/browser/main/StatusBar/index.js +++ b/browser/main/StatusBar/index.js @@ -10,6 +10,10 @@ const { Menu, MenuItem, dialog } = remote const zoomOptions = [0.8, 0.9, 1, 1.1, 1.2, 1.3] +function notify (...args) { + return new window.Notification(...args) +} + class StatusBar extends React.Component { constructor (props) { super(props) @@ -21,17 +25,27 @@ class StatusBar extends React.Component { this.setState({ updateReady: true }, () => { + notify('Update ready!', { + body: 'New Boostnote is ready to be installed.' + }) this.updateApp() }) } + this.updateFoundHandler = (message) => { + notify('Update found!', { + body: 'Preparing to update...' + }) + } } componentDidMount () { ipc.on('update-ready', this.updateReadyHandler) + ipc.on('update-found', this.updateFoundHandler) } componentWillUnmount () { ipc.removeListener('update-ready', this.updateReadyHandler) + ipc.removeListener('update-found', this.updateFoundHandler) } updateApp () { diff --git a/lib/main-app.js b/lib/main-app.js index 8c078247..2a6711f9 100644 --- a/lib/main-app.js +++ b/lib/main-app.js @@ -44,7 +44,7 @@ const updater = new GhReleases(ghReleasesOpts) // Check for updates // `status` returns true if there is a new update available function checkUpdate () { - if (process.platform === 'linux') { + if (process.platform === 'linux' || isUpdateReady) { return true } updater.check((err, status) => { @@ -54,6 +54,7 @@ function checkUpdate () { return } if (status) { + mainWindow.webContents.send('update-found', 'Update available!') updater.download() } }) @@ -69,6 +70,7 @@ updater.on('update-downloaded', (info) => { ipc.on('update-app-confirm', function (event, msg) { console.log('confirmed') if (isUpdateReady) { + mainWindow.removeAllListeners() updater.install() } })