@@ -19,8 +19,8 @@ const browserWindowOpts = {
1919 minHeight : 400 ,
2020 resizable : false ,
2121 skipTaskbar : true , // Hide the app from the Windows taskbar
22+ // TODO ideally we would disable this as use a preload script with a context bridge
2223 webPreferences : {
23- enableRemoteModule : true ,
2424 nodeIntegration : true ,
2525 contextIsolation : false ,
2626 } ,
@@ -37,11 +37,14 @@ const mb = menubar({
3737const menuBuilder = new MenuBuilder ( mb ) ;
3838const contextMenu = menuBuilder . buildMenu ( ) ;
3939
40- /**
41- * Electron Auto Updater only supports macOS and Windows
42- * https://github.com/electron/update-electron-app
43- */
40+ // Register your app as the handler for a custom protocol
41+ app . setAsDefaultProtocolClient ( 'gitify' ) ;
42+
4443if ( isMacOS ( ) || isWindows ( ) ) {
44+ /**
45+ * Electron Auto Updater only supports macOS and Windows
46+ * https://github.com/electron/update-electron-app
47+ */
4548 const updater = new Updater ( mb , menuBuilder ) ;
4649 updater . initialize ( ) ;
4750}
@@ -54,13 +57,6 @@ app.whenReady().then(async () => {
5457 mb . on ( 'ready' , ( ) => {
5558 mb . app . setAppUserModelId ( APPLICATION . ID ) ;
5659
57- /**
58- * TODO: Remove @electron/remote use - see #650
59- * GitHub OAuth 2 Login Flows - Enable Remote Browser Window Launch
60- */
61- require ( '@electron/remote/main' ) . initialize ( ) ;
62- require ( '@electron/remote/main' ) . enable ( mb . window . webContents ) ;
63-
6460 // Tray configuration
6561 mb . tray . setToolTip ( APPLICATION . NAME ) ;
6662 mb . tray . setIgnoreDoubleClickEvents ( true ) ;
@@ -172,3 +168,9 @@ app.whenReady().then(async () => {
172168 app . setLoginItemSettings ( settings ) ;
173169 } ) ;
174170} ) ;
171+
172+ // Handle gitify:// custom protocol URL events for OAuth 2.0 callback
173+ app . on ( 'open-url' , ( event , url ) => {
174+ event . preventDefault ( ) ;
175+ mb . window . webContents . send ( namespacedEvent ( 'auth-callback' ) , url ) ;
176+ } ) ;
0 commit comments