@@ -207,6 +207,22 @@ function hideShareSubmenu() {
207
207
AppMenu . hideShare ( ) ;
208
208
}
209
209
210
+ /**
211
+ * can't use webContents `did-finish-load` event here because
212
+ * metrics aren't set up at that point. renderer app sends custom event
213
+ * `window:renderer-ready` when metrics are set up. If first app launch,
214
+ * send back `app:launched` message at that point.
215
+ *
216
+ * @param {Object } sender original sender of the event
217
+ */
218
+ function rendererReady ( sender ) {
219
+ if ( ! appLaunched ) {
220
+ appLaunched = true ;
221
+ debug ( 'sending `app:launched` msg back' ) ;
222
+ sender . send ( 'app:launched' ) ;
223
+ }
224
+ }
225
+
210
226
// respond to events from the renderer process
211
227
ipc . respondTo ( {
212
228
'app:show-connect-window' : showConnectWindow ,
@@ -215,28 +231,15 @@ ipc.respondTo({
215
231
'window:show-about-dialog' : showAboutDialog ,
216
232
'window:show-share-submenu' : showShareSubmenu ,
217
233
'window:hide-share-submenu' : hideShareSubmenu ,
218
- 'window:show-compass-overview-submenu' : showCompassOverview
234
+ 'window:show-compass-overview-submenu' : showCompassOverview ,
235
+ 'window:renderer-ready' : rendererReady
219
236
} ) ;
220
237
221
238
// respond to events from the main process
222
239
app . on ( 'window:show-about-dialog' , showAboutDialog ) ;
223
240
app . on ( 'app:show-connect-window' , showConnectWindow ) ;
224
241
app . on ( 'app:show-help-window' , showHelpWindow ) ;
225
242
226
- /**
227
- * can't use webContents `did-finish-load` event here because
228
- * metrics aren't set up at that point. renderer app sends custom event
229
- * `renderer ready` when metrics are set up. If first app launch, send back
230
- * `app launched` message at that point.
231
- */
232
- app . on ( 'window:renderer-ready' , function ( arg , event ) {
233
- if ( ! appLaunched ) {
234
- appLaunched = true ;
235
- debug ( 'sending `app:launched` msg back' ) ;
236
- event . sender . send ( 'app:launched' ) ;
237
- }
238
- } ) ;
239
-
240
243
app . on ( 'before-quit' , function ( ) {
241
244
debug ( 'sending `app:quit` msg' ) ;
242
245
_ . first ( BrowserWindow . getAllWindows ( ) ) . webContents . send ( 'app:quit' ) ;
0 commit comments