File tree Expand file tree Collapse file tree 2 files changed +16
-13
lines changed
components/intercept/config Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { logError } from '../../../errors';
8
8
9
9
import { Interceptor } from '../../../model/interception/interceptors' ;
10
10
import { UiStore } from '../../../model/ui-store' ;
11
+ import { DesktopApi } from '../../../services/desktop-api' ;
11
12
12
13
import { uploadFile } from '../../../util/ui' ;
13
14
import { Button , SecondaryButton , UnstyledButton } from '../../common/inputs' ;
@@ -120,12 +121,6 @@ function getReadablePath(path: string) {
120
121
}
121
122
}
122
123
123
- declare global {
124
- interface Window {
125
- desktopApi ?: { selectApplication : ( ) => Promise < string | undefined > } ;
126
- }
127
- }
128
-
129
124
@inject ( 'uiStore' )
130
125
@observer
131
126
class ElectronConfig extends React . Component < {
@@ -147,13 +142,9 @@ class ElectronConfig extends React.Component<{
147
142
}
148
143
149
144
selectApplication = async ( ) => {
150
- const useNativePicker = window . desktopApi ?. selectApplication ;
145
+ const appPicker = DesktopApi . selectApplication ?? ( ( ) => uploadFile ( 'path' ) ) ;
151
146
152
- const pathToApplication = await (
153
- useNativePicker
154
- ? window . desktopApi ?. selectApplication ( )
155
- : uploadFile ( 'path' )
156
- ) ;
147
+ const pathToApplication = await ( appPicker ( ) ) ;
157
148
158
149
if ( ! pathToApplication ) {
159
150
this . props . closeSelf ( ) ;
Original file line number Diff line number Diff line change @@ -19,4 +19,16 @@ export async function getDesktopInjectedValue(key: DesktopInjectedKey): Promise<
19
19
} ) ;
20
20
}
21
21
// Note that if we're running in a browser, not the desktop shell, this _never_ resolves.
22
- }
22
+ }
23
+
24
+ declare global {
25
+ interface Window {
26
+ desktopApi ?: DesktopApi ;
27
+ }
28
+ }
29
+
30
+ interface DesktopApi {
31
+ selectApplication ?: ( ) => Promise < string | undefined >
32
+ }
33
+
34
+ export const DesktopApi : DesktopApi = window . desktopApi ?? { } ;
You can’t perform that action at this time.
0 commit comments