@@ -13,6 +13,7 @@ const audio = require('./windows/audio')
13
13
const player = require ( './windows/player' )
14
14
const AudioLibrary = require ( './lib/audio-library' )
15
15
const log = require ( 'electron-log' )
16
+ const autoUpdater = require ( 'electron-updater' ) . autoUpdater
16
17
17
18
// handle uncaught exceptions before calling any functions
18
19
process . on ( 'uncaughtException' , ( err ) => {
@@ -88,6 +89,43 @@ app.on('ready', function appReady () {
88
89
ipcMain . on ( 'recall' , recall )
89
90
ipcMain . on ( 'sync-state' , syncState )
90
91
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
+
91
129
// ACTIONS
92
130
// NOTE: I really don't like having all of these actions stuck in this scope.
93
131
// Would be nice to move this to a separate file eventually. -ungoldman
@@ -156,9 +194,9 @@ app.on('ready', function appReady () {
156
194
broadcast ( 'paused' )
157
195
}
158
196
159
- function playPause ( ) {
160
- state . playing ? pause ( ) : play ( )
161
- }
197
+ // function playPause () {
198
+ // state.playing ? pause() : play()
199
+ // }
162
200
163
201
function prev ( ) {
164
202
broadcast ( 'new-track' , al . prev ( ) )
0 commit comments