@@ -19,7 +19,6 @@ if (process.env.PROD) {
1919
2020let mainWindow ;
2121let authCode ;
22- let authResponse ;
2322
2423function logEverywhere ( ...toBeLogged ) {
2524 console . log ( ...toBeLogged ) ;
@@ -28,16 +27,64 @@ function logEverywhere(...toBeLogged) {
2827 }
2928}
3029
31- const protocol = isDev ? "dev-app" : "prod-app" ;
32- const deeplink = new Deeplink ( { app, mainWindow, protocol, isDev } ) ;
30+ const protocol = isDev ? 'overvuedev' : 'overvue'
31+ const deeplink = new Deeplink ( {
32+ app,
33+ mainWindow,
34+ protocol,
35+ isDev ,
36+ debugLogging : true ,
37+ electronPath : '../../node_modules/electron/dist/electron.exe'
38+ } ) ;
3339// ipcMain.handle('slackAuth', slackAuth)
3440
41+ let deeplinkingUrl ;
42+
43+ function customDeepLink ( ) {
44+ if ( isDev && process . platform === 'win32' ) {
45+ // Set the path of electron.exe and your app.
46+ // These two additional parameters are only available on windows.
47+ // Setting this is required to get this working in dev mode.
48+ app . setAsDefaultProtocolClient ( 'overvuedev' , process . execPath , [
49+ resolve ( process . argv [ 1 ] )
50+ ] ) ;
51+ } else {
52+ app . setAsDefaultProtocolClient ( 'overvue' ) ;
53+ }
54+
55+ app . on ( 'open-url' , function ( event , url ) {
56+ event . preventDefault ( ) ;
57+ deeplinkingUrl = url ;
58+ } ) ;
59+
60+ // Force single application instance
61+ const gotTheLock = app . requestSingleInstanceLock ( ) ;
62+
63+ if ( ! gotTheLock ) {
64+ app . quit ( ) ;
65+ return ;
66+ } else {
67+ app . on ( 'second-instance' , ( e , argv ) => {
68+ if ( process . platform !== 'darwin' ) {
69+ // Find the arg that is our custom protocol url and store it
70+ deeplinkingUrl = argv . find ( ( arg ) => arg . startsWith ( 'overvuedev://test' ) ) ;
71+ }
72+
73+ if ( myWindow ) {
74+ if ( myWindow . isMinimized ( ) ) myWindow . restore ( ) ;
75+ myWindow . focus ( ) ;
76+ }
77+ } )
78+ }
79+ }
80+
81+
3582function getSlackAuth ( ) {
3683 const authData = {
3784 client_id : clientId ,
3885 client_secret : clientSecret ,
3986 code : authCode ,
40- redirect_uri : 'overvue://slack'
87+ redirect_uri : isDev ? 'overvuedev://test' : 'overvue://slack'
4188 }
4289
4390 const request = net . request ( {
@@ -72,7 +119,6 @@ function getSlackToken () {
72119 getSlackAuth ( )
73120 } ) ;
74121}
75- //overvue://slack/?code=2696943977700.2730026875664.c754c0f5326f5c8495cd66fb374c5ea441c610b2cff0064dd4832b0290db6b5b
76122
77123function createWindow ( ) {
78124 /**
@@ -89,6 +135,7 @@ function createWindow() {
89135 }
90136 } ) ;
91137
138+ logEverywhere ( 'current protocol ' , deeplink . getProtocol ( ) )
92139 mainWindow . loadURL ( process . env . APP_URL )
93140
94141 mainWindow . on ( "closed" , ( ) => {
0 commit comments