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';
88
99import { Interceptor } from '../../../model/interception/interceptors' ;
1010import { UiStore } from '../../../model/ui-store' ;
11+ import { DesktopApi } from '../../../services/desktop-api' ;
1112
1213import { uploadFile } from '../../../util/ui' ;
1314import { Button , SecondaryButton , UnstyledButton } from '../../common/inputs' ;
@@ -120,12 +121,6 @@ function getReadablePath(path: string) {
120121 }
121122}
122123
123- declare global {
124- interface Window {
125- desktopApi ?: { selectApplication : ( ) => Promise < string | undefined > } ;
126- }
127- }
128-
129124@inject ( 'uiStore' )
130125@observer
131126class ElectronConfig extends React . Component < {
@@ -147,13 +142,9 @@ class ElectronConfig extends React.Component<{
147142 }
148143
149144 selectApplication = async ( ) => {
150- const useNativePicker = window . desktopApi ?. selectApplication ;
145+ const appPicker = DesktopApi . selectApplication ?? ( ( ) => uploadFile ( 'path' ) ) ;
151146
152- const pathToApplication = await (
153- useNativePicker
154- ? window . desktopApi ?. selectApplication ( )
155- : uploadFile ( 'path' )
156- ) ;
147+ const pathToApplication = await ( appPicker ( ) ) ;
157148
158149 if ( ! pathToApplication ) {
159150 this . props . closeSelf ( ) ;
Original file line number Diff line number Diff line change @@ -19,4 +19,16 @@ export async function getDesktopInjectedValue(key: DesktopInjectedKey): Promise<
1919 } ) ;
2020 }
2121 // 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