From d5265407b9c2fb3698a8be1edea930852a61b728 Mon Sep 17 00:00:00 2001 From: Rokt33r Date: Sun, 22 Nov 2015 15:57:44 +0900 Subject: [PATCH] No node-notifier --- atom-lib/updater.js | 42 ------------------------------- browser/main/index.js | 10 ++++++++ main.js | 57 ++++++++++++++++++++++++++++--------------- package.json | 1 - 4 files changed, 47 insertions(+), 63 deletions(-) delete mode 100644 atom-lib/updater.js diff --git a/atom-lib/updater.js b/atom-lib/updater.js deleted file mode 100644 index 38a112fb..00000000 --- a/atom-lib/updater.js +++ /dev/null @@ -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 diff --git a/browser/main/index.js b/browser/main/index.js index 028a2180..9be3d9ed 100644 --- a/browser/main/index.js +++ b/browser/main/index.js @@ -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 = ( diff --git a/main.js b/main.js index e0b65c68..e120de36 100644 --- a/main.js +++ b/main.js @@ -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 diff --git a/package.json b/package.json index 12f23ca4..d8645e79 100644 --- a/package.json +++ b/package.json @@ -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"