Skip to content

Commit d526540

Browse files
committed
No node-notifier
1 parent 954b3e9 commit d526540

4 files changed

Lines changed: 47 additions & 63 deletions

File tree

atom-lib/updater.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

browser/main/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ window.addEventListener('online', function () {
1818
ipc.send('check-update', 'check-update')
1919
})
2020

21+
function notify (...args) {
22+
return new window.Notification(...args)
23+
}
24+
25+
ipc.on('notify', function (title, message) {
26+
notify(title, {
27+
body: message
28+
})
29+
})
30+
2131
let routes = (
2232
<Route path='/' component={MainPage}>
2333
<IndexRoute name='home' component={HomePage}/>

main.js

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,59 @@ var update = null
1818
// if (process.platform !== 'darwin') app.quit()
1919
// })
2020

21-
var version = app.getVersion()
22-
var versionText = (version == null || version.length === 0) ? 'DEV version' : 'v' + version
23-
var nn = require('node-notifier')
24-
var updater = require('./atom-lib/updater')
25-
var path = require('path')
21+
var autoUpdater = require('auto-updater')
2622

2723
var appQuit = false
2824

29-
updater
25+
var version = app.getVersion()
26+
var versionText = (version == null || version.length === 0) ? 'DEV version' : 'v' + version
27+
var versionNotified = false
28+
autoUpdater
3029
.on('update-downloaded', function (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) {
31-
nn.notify({
32-
title: 'Ready to Update!! ' + versionText,
33-
icon: path.join(__dirname, '/resources/favicon-230x230.png'),
34-
message: 'Click update button on Main window: ' + releaseName
35-
})
3630
update = quitAndUpdate
3731

38-
if (mainWindow != null && !mainWindow.webContents.isLoading()) {
32+
if (mainWindow != null) {
33+
mainWindow.webContents.send('notify', 'Ready to Update! ' + releaseName, 'Click update button on Main window.')
3934
mainWindow.webContents.send('update-available', 'Update available!')
4035
}
4136
})
37+
.on('error', function (err, message) {
38+
console.error(err)
39+
if (mainWindow != null && !versionNotified) {
40+
mainWindow.webContents.send('notify', 'Updater error!', message)
41+
}
42+
})
43+
// .on('checking-for-update', function () {
44+
// // Connecting
45+
// console.log('checking...')
46+
// })
47+
.on('update-available', function () {
48+
if (mainWindow != null) {
49+
mainWindow.webContents.send('notify', 'Update is available!', 'Download started.. wait for the update ready.')
50+
}
51+
})
52+
.on('update-not-available', function () {
53+
if (mainWindow != null && !versionNotified) {
54+
versionNotified = true
55+
mainWindow.webContents.send('notify', 'Latest Build!! ' + versionText, 'Hope you to enjoy our app :D')
56+
}
57+
})
4258

4359
app.on('ready', function () {
4460
app.on('before-quit', function () {
4561
appQuit = true
4662
})
4763
console.log('Version ' + version)
48-
updater.setFeedUrl('http://orbital.b00st.io/rokt33r/boost-dev/latest?version=' + version)
49-
updater.checkForUpdates()
64+
autoUpdater.setFeedUrl('http://orbital.b00st.io/rokt33r/boost-dev/latest?version=' + version)
5065
// menu start
5166
var template = require('./atom-lib/menu-template')
5267

5368
setInterval(function () {
54-
if (update == null) updater.checkForUpdates()
69+
if (update == null) autoUpdater.checkForUpdates()
5570
}, 1000 * 60 * 60 * 24)
5671

5772
ipc.on('check-update', function (event, msg) {
58-
if (update == null) updater.checkForUpdates()
73+
if (update == null) autoUpdater.checkForUpdates()
5974
})
6075

6176
ipc.on('update-app', function (event, msg) {
@@ -93,11 +108,13 @@ app.on('ready', function () {
93108
e.preventDefault()
94109
mainWindow.hide()
95110
})
96-
if (update != null) {
97-
mainWindow.webContents.on('did-finish-load', function () {
111+
mainWindow.webContents.on('did-finish-load', function () {
112+
if (update != null) {
98113
mainWindow.webContents.send('update-available', 'whoooooooh!')
99-
})
100-
}
114+
} else {
115+
autoUpdater.checkForUpdates()
116+
}
117+
})
101118

102119
app.on('activate-with-no-open-windows', function () {
103120
if (mainWindow == null) return null

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
"markdown-it": "^4.3.1",
4545
"md5": "^2.0.0",
4646
"moment": "^2.10.3",
47-
"node-notifier": "^4.2.3",
4847
"socket.io-client": "^1.3.6",
4948
"superagent": "^1.2.0",
5049
"superagent-promise": "^1.0.3"

0 commit comments

Comments
 (0)