1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

fix update error

This commit is contained in:
Dick Choi
2016-09-21 16:00:18 +09:00
parent 8a9d4df6c7
commit 6bb9366ec8
2 changed files with 17 additions and 1 deletions

View File

@@ -10,6 +10,10 @@ const { Menu, MenuItem, dialog } = remote
const zoomOptions = [0.8, 0.9, 1, 1.1, 1.2, 1.3] 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 { class StatusBar extends React.Component {
constructor (props) { constructor (props) {
super(props) super(props)
@@ -21,17 +25,27 @@ class StatusBar extends React.Component {
this.setState({ this.setState({
updateReady: true updateReady: true
}, () => { }, () => {
notify('Update ready!', {
body: 'New Boostnote is ready to be installed.'
})
this.updateApp() this.updateApp()
}) })
} }
this.updateFoundHandler = (message) => {
notify('Update found!', {
body: 'Preparing to update...'
})
}
} }
componentDidMount () { componentDidMount () {
ipc.on('update-ready', this.updateReadyHandler) ipc.on('update-ready', this.updateReadyHandler)
ipc.on('update-found', this.updateFoundHandler)
} }
componentWillUnmount () { componentWillUnmount () {
ipc.removeListener('update-ready', this.updateReadyHandler) ipc.removeListener('update-ready', this.updateReadyHandler)
ipc.removeListener('update-found', this.updateFoundHandler)
} }
updateApp () { updateApp () {

View File

@@ -44,7 +44,7 @@ const updater = new GhReleases(ghReleasesOpts)
// Check for updates // Check for updates
// `status` returns true if there is a new update available // `status` returns true if there is a new update available
function checkUpdate () { function checkUpdate () {
if (process.platform === 'linux') { if (process.platform === 'linux' || isUpdateReady) {
return true return true
} }
updater.check((err, status) => { updater.check((err, status) => {
@@ -54,6 +54,7 @@ function checkUpdate () {
return return
} }
if (status) { if (status) {
mainWindow.webContents.send('update-found', 'Update available!')
updater.download() updater.download()
} }
}) })
@@ -69,6 +70,7 @@ updater.on('update-downloaded', (info) => {
ipc.on('update-app-confirm', function (event, msg) { ipc.on('update-app-confirm', function (event, msg) {
console.log('confirmed') console.log('confirmed')
if (isUpdateReady) { if (isUpdateReady) {
mainWindow.removeAllListeners()
updater.install() updater.install()
} }
}) })