@@ -94,7 +94,7 @@ var shouldQuit = app.makeSingleInstance(function(commandLine, workingDirectory)
9494} )
9595
9696if ( shouldQuit ) {
97- app . quit ( )
97+ quitApp ( )
9898 return
9999}
100100
@@ -114,82 +114,71 @@ function notify (title, body) {
114114}
115115
116116var isUpdateReady = false
117- if ( process . platform === 'darwin' ) {
118- autoUpdater . setFeedURL ( 'https://orbital.b00st.io/rokt33r/boost-app/latest?version=' + version )
119- autoUpdater
120- . on ( 'update-downloaded' , function ( event , releaseNotes , releaseName , releaseDate , updateUrl , quitAndUpdate ) {
121- update = quitAndUpdate
122-
123- if ( mainWindow != null ) {
124- notify ( 'Ready to Update! ' + releaseName , 'Click update button on Main window.' )
125- mainWindow . webContents . send ( 'update-available' , 'Update available!' )
126- }
127- } )
128- . on ( 'error' , function ( err , message ) {
129- console . error ( 'error' )
130- console . error ( err )
131- if ( ! versionNotified ) {
132- notify ( 'Updater error!' , message )
133- }
134- } )
135- . on ( 'update-available' , function ( ) {
136- notify ( 'Update is available!' , 'Download started.. wait for the update ready.' )
137- } )
138- . on ( 'update-not-available' , function ( ) {
139- if ( ! versionNotified ) {
140- versionNotified = true
141- notify ( 'Latest Build!! ' + versionText , 'Hope you to enjoy our app :D' )
142- }
143- } )
144- } else if ( process . platform === 'win32' ) {
145- var GhReleases = require ( 'electron-gh-releases' )
117+ var GhReleases = require ( 'electron-gh-releases' )
146118
147- var ghReleasesOpts = {
148- repo : 'BoostIO/boost-releases' ,
149- currentVersion : app . getVersion ( )
150- }
119+ var ghReleasesOpts = {
120+ repo : 'BoostIO/boost-releases' ,
121+ currentVersion : app . getVersion ( )
122+ }
151123
152- const updater = new GhReleases ( ghReleasesOpts )
124+ const updater = new GhReleases ( ghReleasesOpts )
153125
154- // Check for updates
155- // `status` returns true if there is a new update available
156- function checkUpdate ( ) {
157- updater . check ( ( err , status ) => {
158- if ( err ) {
159- console . error ( err )
160- if ( ! versionNotified ) notify ( 'Updater error!' , message )
161- }
162- if ( ! err ) {
163- if ( status ) {
164- notify ( 'Update is available!' , 'Download started.. wait for the update ready.' )
165- updater . download ( )
166- } else {
167- if ( ! versionNotified ) {
168- versionNotified = true
169- notify ( 'Latest Build!! ' + versionText , 'Hope you to enjoy our app :D' )
170- }
126+ // Check for updates
127+ // `status` returns true if there is a new update available
128+ function checkUpdate ( ) {
129+ updater . check ( ( err , status ) => {
130+ if ( err ) {
131+ console . error ( err )
132+ if ( ! versionNotified ) notify ( 'Updater error!' , message )
133+ }
134+ if ( ! err ) {
135+ if ( status ) {
136+ notify ( 'Update is available!' , 'Download started.. wait for the update ready.' )
137+ updater . download ( )
138+ } else {
139+ if ( ! versionNotified ) {
140+ versionNotified = true
141+ notify ( 'Latest Build!! ' + versionText , 'Hope you to enjoy our app :D' )
171142 }
172143 }
173- } )
174- }
175-
176- updater . on ( 'update-downloaded' , ( info ) => {
177- if ( mainWindow != null ) {
178- notify ( 'Ready to Update!' , 'Click update button on Main window.' )
179- mainWindow . webContents . send ( 'update-available' , 'Update available!' )
180- isUpdateReady = true
181144 }
182145 } )
183146}
184147
148+ updater . on ( 'update-downloaded' , ( info ) => {
149+ if ( mainWindow != null ) {
150+ notify ( 'Ready to Update!' , 'Click update button on Main window.' )
151+ mainWindow . webContents . send ( 'update-available' , 'Update available!' )
152+ isUpdateReady = true
153+ }
154+ } )
155+
185156const nodeIpc = require ( '@rokt33r/node-ipc' )
186157nodeIpc . config . id = 'node'
187158nodeIpc . config . retry = 1500
188159// nodeIpc.config.silent = true
189160
161+ function spawnFinder ( ) {
162+ if ( process . platform === 'darwin' ) {
163+ var finderArgv = [ path . join ( __dirname , 'finder.js' ) , '--finder' ]
164+ if ( _ . find ( process . argv , a => a === '--hot' ) ) finderArgv . push ( '--hot' )
165+ finderProcess = ChildProcess
166+ . execFile ( process . execPath , finderArgv )
167+ }
168+ }
169+
190170nodeIpc . serve (
191171 path . join ( app . getPath ( 'userData' ) , 'boost.service' ) ,
192172 function ( ) {
173+ nodeIpc . server . on (
174+ 'connect' ,
175+ function ( socket ) {
176+ socket . on ( 'close' , function ( ) {
177+ console . log ( 'socket dead' )
178+ if ( ! appQuit ) spawnFinder ( )
179+ } )
180+ }
181+ )
193182 nodeIpc . server . on (
194183 'message' ,
195184 function ( data , socket ) {
@@ -209,8 +198,12 @@ nodeIpc.serve(
209198function format ( payload ) {
210199 switch ( payload . type ) {
211200 case 'show-main-window' :
212- mainWindow . minimize ( )
213- mainWindow . restore ( )
201+ if ( process . platform === 'darwin' ) {
202+ mainWindow . show ( )
203+ } else {
204+ mainWindow . minimize ( )
205+ mainWindow . restore ( )
206+ }
214207 break
215208 case 'copy-finder' :
216209 mainWindow . webContents . send ( 'copy-finder' )
@@ -220,6 +213,7 @@ function format (payload) {
220213 break
221214 }
222215}
216+
223217function quitApp ( ) {
224218 appQuit = true
225219 if ( finderProcess ) finderProcess . kill ( )
@@ -228,8 +222,9 @@ function quitApp () {
228222
229223app . on ( 'ready' , function ( ) {
230224 app . on ( 'before-quit' , function ( ) {
231- if ( finderProcess ) finderProcess . kill ( )
225+ console . log ( 'before quite' )
232226 appQuit = true
227+ if ( finderProcess ) finderProcess . kill ( )
233228 } )
234229
235230 var template = require ( './atom-lib/menu-template' )
@@ -281,10 +276,7 @@ app.on('ready', function () {
281276
282277 mainWindow . webContents . on ( 'did-finish-load' , function ( ) {
283278 if ( finderProcess == null && process . platform === 'darwin' ) {
284- var finderArgv = [ path . join ( __dirname , 'finder.js' ) , '--finder' ]
285- if ( _ . find ( process . argv , a => a === '--hot' ) ) finderArgv . push ( '--hot' )
286- finderProcess = ChildProcess
287- . execFile ( process . execPath , finderArgv )
279+ spawnFinder ( )
288280 } else {
289281 finderWindow = require ( './atom-lib/finder-window' )
290282
0 commit comments