diff --git a/atom-lib/updater.js b/atom-lib/updater.js index d506b643..38a112fb 100644 --- a/atom-lib/updater.js +++ b/atom-lib/updater.js @@ -5,33 +5,38 @@ 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.join(__dirname, 'browser/main/resources/favicon-230x230.png'), + 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.join(__dirname, 'browser/main/resources/favicon-230x230.png'), + icon: path.resolve(__dirname, '../resources/favicon-230x230.png'), message: 'Download started.. wait for the update ready.' }) }) .on('update-not-available', function () { - nn.notify({ - title: 'Latest Build!! ' + versionText, - icon: path.join(__dirname, 'browser/main/resources/favicon-230x230.png'), - message: 'Hope you to enjoy our app :D' - }) + 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 a749bdbe..028a2180 100644 --- a/browser/main/index.js +++ b/browser/main/index.js @@ -11,8 +11,12 @@ require('../styles/main/index.styl') import { openModal } from 'boost/modal' import Tutorial from 'boost/components/modal/Tutorial' import activityRecord from 'boost/activityRecord' +import ipc from 'ipc' activityRecord.init() +window.addEventListener('online', function () { + ipc.send('check-update', 'check-update') +}) let routes = ( diff --git a/main.js b/main.js index d3b9bd7d..1d63eb1c 100644 --- a/main.js +++ b/main.js @@ -30,8 +30,8 @@ updater .on('update-downloaded', function (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) { nn.notify({ title: 'Ready to Update!! ' + versionText, - icon: path.join(__dirname, 'browser/main/resources/favicon-230x230.png'), - message: 'Click tray icon to update app: ' + releaseName + icon: path.join(__dirname, '/resources/favicon-230x230.png'), + message: 'Click update button on Main window: ' + releaseName }) update = quitAndUpdate @@ -50,6 +50,14 @@ app.on('ready', function () { // menu start var template = require('./atom-lib/menu-template') + setInterval(function () { + updater.checkForUpdates() + }, 1000 * 60 * 60 * 24) + + ipc.on('check-update', function (event, msg) { + updater.checkForUpdates() + }) + ipc.on('update-app', function (event, msg) { if (update != null) { appQuit = true