@@ -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
2723var 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
4359app . 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
0 commit comments