@@ -13,6 +13,7 @@ const audio = require('./windows/audio')
1313const player = require ( './windows/player' )
1414const AudioLibrary = require ( './lib/audio-library' )
1515const log = require ( 'electron-log' )
16+ const autoUpdater = require ( 'electron-updater' ) . autoUpdater
1617
1718// handle uncaught exceptions before calling any functions
1819process . on ( 'uncaughtException' , ( err ) => {
@@ -88,6 +89,43 @@ app.on('ready', function appReady () {
8889 ipcMain . on ( 'recall' , recall )
8990 ipcMain . on ( 'sync-state' , syncState )
9091
92+ // register autoUpdater
93+ if ( ! process . env . DEV_SERVER ) {
94+ setTimeout ( ( ) => {
95+ log . info ( 'autoUpdater: Auto update initalized...' )
96+ autoUpdater . checkForUpdatesAndNotify ( )
97+ } , 1000 * 3 )
98+ }
99+
100+ autoUpdater . on ( 'error' , ( err ) => {
101+ broadcast ( 'au:error' , err )
102+ console . error ( err )
103+ } )
104+
105+ autoUpdater . on ( 'checking-for-update' , ( ) => {
106+ log . info ( 'autoUpdater: Checking for update...' )
107+ broadcast ( 'au:checking-for-update' )
108+ } )
109+
110+ autoUpdater . on ( 'update-available' , ( info ) => {
111+ log . info ( 'autoUpdater: Update available!' )
112+ broadcast ( 'au:update-available' , info )
113+ } )
114+
115+ autoUpdater . on ( 'update-not-available' , ( info ) => {
116+ log . info ( 'autoUpdater: No update available' )
117+ broadcast ( 'au:update-not-available' , info )
118+ } )
119+
120+ autoUpdater . on ( 'download-progress' , ( progress ) => {
121+ broadcast ( 'au:progress' , progress )
122+ } )
123+
124+ autoUpdater . on ( 'update-downloaded' , ( info ) => {
125+ log . info ( 'autoUpdater: Update downloaded' )
126+ broadcast ( 'au:update-downloaded' , info )
127+ } )
128+
91129 // ACTIONS
92130 // NOTE: I really don't like having all of these actions stuck in this scope.
93131 // Would be nice to move this to a separate file eventually. -ungoldman
@@ -156,9 +194,9 @@ app.on('ready', function appReady () {
156194 broadcast ( 'paused' )
157195 }
158196
159- function playPause ( ) {
160- state . playing ? pause ( ) : play ( )
161- }
197+ // function playPause () {
198+ // state.playing ? pause() : play()
199+ // }
162200
163201 function prev ( ) {
164202 broadcast ( 'new-track' , al . prev ( ) )
0 commit comments