1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

No node-notifier

This commit is contained in:
Rokt33r
2015-11-22 15:57:44 +09:00
parent 954b3e9fc5
commit d5265407b9
4 changed files with 47 additions and 63 deletions

View File

@@ -1,42 +0,0 @@
var autoUpdater = require('auto-updater')
var nn = require('node-notifier')
var app = require('app')
var path = require('path')
var version = app.getVersion()
var versionText = (version == null || version.length === 0) ? 'DEV version' : 'v' + version
var versionNotified = false
autoUpdater
.on('error', function (err, message) {
console.error(err)
console.error(message)
console.log(path.resolve(__dirname, '../resources/favicon-230x230.png'))
nn.notify({
title: 'Error! ' + versionText,
icon: path.resolve(__dirname, '../resources/favicon-230x230.png'),
message: message
})
})
// .on('checking-for-update', function () {
// // Connecting
// console.log('checking...')
// })
.on('update-available', function () {
nn.notify({
title: 'Update is available!! ' + versionText,
icon: path.resolve(__dirname, '../resources/favicon-230x230.png'),
message: 'Download started.. wait for the update ready.'
})
})
.on('update-not-available', function () {
if (!versionNotified) {
nn.notify({
title: 'Latest Build!! ' + versionText,
icon: path.resolve(__dirname, '../resources/favicon-230x230.png'),
message: 'Hope you to enjoy our app :D'
})
versionNotified = true
}
})
module.exports = autoUpdater

View File

@@ -18,6 +18,16 @@ window.addEventListener('online', function () {
ipc.send('check-update', 'check-update')
})
function notify (...args) {
return new window.Notification(...args)
}
ipc.on('notify', function (title, message) {
notify(title, {
body: message
})
})
let routes = (
<Route path='/' component={MainPage}>
<IndexRoute name='home' component={HomePage}/>

57
main.js
View File

@@ -18,44 +18,59 @@ var update = null
// if (process.platform !== 'darwin') app.quit()
// })
var version = app.getVersion()
var versionText = (version == null || version.length === 0) ? 'DEV version' : 'v' + version
var nn = require('node-notifier')
var updater = require('./atom-lib/updater')
var path = require('path')
var autoUpdater = require('auto-updater')
var appQuit = false
updater
var version = app.getVersion()
var versionText = (version == null || version.length === 0) ? 'DEV version' : 'v' + version
var versionNotified = false
autoUpdater
.on('update-downloaded', function (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) {
nn.notify({
title: 'Ready to Update!! ' + versionText,
icon: path.join(__dirname, '/resources/favicon-230x230.png'),
message: 'Click update button on Main window: ' + releaseName
})
update = quitAndUpdate
if (mainWindow != null && !mainWindow.webContents.isLoading()) {
if (mainWindow != null) {
mainWindow.webContents.send('notify', 'Ready to Update! ' + releaseName, 'Click update button on Main window.')
mainWindow.webContents.send('update-available', 'Update available!')
}
})
.on('error', function (err, message) {
console.error(err)
if (mainWindow != null && !versionNotified) {
mainWindow.webContents.send('notify', 'Updater error!', message)
}
})
// .on('checking-for-update', function () {
// // Connecting
// console.log('checking...')
// })
.on('update-available', function () {
if (mainWindow != null) {
mainWindow.webContents.send('notify', 'Update is available!', 'Download started.. wait for the update ready.')
}
})
.on('update-not-available', function () {
if (mainWindow != null && !versionNotified) {
versionNotified = true
mainWindow.webContents.send('notify', 'Latest Build!! ' + versionText, 'Hope you to enjoy our app :D')
}
})
app.on('ready', function () {
app.on('before-quit', function () {
appQuit = true
})
console.log('Version ' + version)
updater.setFeedUrl('http://orbital.b00st.io/rokt33r/boost-dev/latest?version=' + version)
updater.checkForUpdates()
autoUpdater.setFeedUrl('http://orbital.b00st.io/rokt33r/boost-dev/latest?version=' + version)
// menu start
var template = require('./atom-lib/menu-template')
setInterval(function () {
if (update == null) updater.checkForUpdates()
if (update == null) autoUpdater.checkForUpdates()
}, 1000 * 60 * 60 * 24)
ipc.on('check-update', function (event, msg) {
if (update == null) updater.checkForUpdates()
if (update == null) autoUpdater.checkForUpdates()
})
ipc.on('update-app', function (event, msg) {
@@ -93,11 +108,13 @@ app.on('ready', function () {
e.preventDefault()
mainWindow.hide()
})
if (update != null) {
mainWindow.webContents.on('did-finish-load', function () {
mainWindow.webContents.on('did-finish-load', function () {
if (update != null) {
mainWindow.webContents.send('update-available', 'whoooooooh!')
})
}
} else {
autoUpdater.checkForUpdates()
}
})
app.on('activate-with-no-open-windows', function () {
if (mainWindow == null) return null

View File

@@ -44,7 +44,6 @@
"markdown-it": "^4.3.1",
"md5": "^2.0.0",
"moment": "^2.10.3",
"node-notifier": "^4.2.3",
"socket.io-client": "^1.3.6",
"superagent": "^1.2.0",
"superagent-promise": "^1.0.3"