@@ -19,7 +19,6 @@ if (process.env.PROD) {
19
19
20
20
let mainWindow ;
21
21
let authCode ;
22
- let authResponse ;
23
22
24
23
function logEverywhere ( ...toBeLogged ) {
25
24
console . log ( ...toBeLogged ) ;
@@ -28,16 +27,64 @@ function logEverywhere(...toBeLogged) {
28
27
}
29
28
}
30
29
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
+ } ) ;
33
39
// ipcMain.handle('slackAuth', slackAuth)
34
40
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
+
35
82
function getSlackAuth ( ) {
36
83
const authData = {
37
84
client_id : clientId ,
38
85
client_secret : clientSecret ,
39
86
code : authCode ,
40
- redirect_uri : 'overvue://slack'
87
+ redirect_uri : isDev ? 'overvuedev://test' : 'overvue://slack'
41
88
}
42
89
43
90
const request = net . request ( {
@@ -72,7 +119,6 @@ function getSlackToken () {
72
119
getSlackAuth ( )
73
120
} ) ;
74
121
}
75
- //overvue://slack/?code=2696943977700.2730026875664.c754c0f5326f5c8495cd66fb374c5ea441c610b2cff0064dd4832b0290db6b5b
76
122
77
123
function createWindow ( ) {
78
124
/**
@@ -89,6 +135,7 @@ function createWindow() {
89
135
}
90
136
} ) ;
91
137
138
+ logEverywhere ( 'current protocol ' , deeplink . getProtocol ( ) )
92
139
mainWindow . loadURL ( process . env . APP_URL )
93
140
94
141
mainWindow . on ( "closed" , ( ) => {
0 commit comments