|
@@ -8,28 +8,7 @@ import {
|
8
|
8
|
DeepLinkingMobilePage,
|
9
|
9
|
NoMobileApp
|
10
|
10
|
} from './components';
|
11
|
|
-import { _shouldShowDeepLinkingDesktopPage }
|
12
|
|
- from './shouldShowDeepLinkingDesktopPage';
|
13
|
|
-
|
14
|
|
-/**
|
15
|
|
- * Promise that resolves when the window load event is received.
|
16
|
|
- *
|
17
|
|
- * @type {Promise<void>}
|
18
|
|
- */
|
19
|
|
-const windowLoadedPromise = new Promise(resolve => {
|
20
|
|
- /**
|
21
|
|
- * Handler for the window load event.
|
22
|
|
- *
|
23
|
|
- * @returns {void}
|
24
|
|
- */
|
25
|
|
- function onWindowLoad() {
|
26
|
|
- resolve();
|
27
|
|
- window.removeEventListener('load', onWindowLoad);
|
28
|
|
- }
|
29
|
|
-
|
30
|
|
- window.addEventListener('load', onWindowLoad);
|
31
|
|
-});
|
32
|
|
-
|
|
11
|
+import { _openDesktopApp } from './openDesktopApp';
|
33
|
12
|
|
34
|
13
|
/**
|
35
|
14
|
* Generates a deep linking URL based on the current window URL.
|
|
@@ -96,23 +75,17 @@ export function getDeepLinkingPage(state) {
|
96
|
75
|
return Promise.resolve();
|
97
|
76
|
}
|
98
|
77
|
|
99
|
|
- return _shouldShowDeepLinkingDesktopPage().then(
|
|
78
|
+ return _openDesktopApp().then(
|
100
|
79
|
// eslint-disable-next-line no-confusing-arrow
|
101
|
|
- show => show ? DeepLinkingDesktopPage : undefined);
|
|
80
|
+ result => result ? DeepLinkingDesktopPage : undefined);
|
102
|
81
|
}
|
103
|
82
|
|
104
|
83
|
/**
|
105
|
84
|
* Opens the desktop app.
|
106
|
85
|
*
|
107
|
|
- * @returns {void}
|
|
86
|
+ * @returns {Promise<boolean>} - Resolves with true if the attempt to open the desktop app was successful and resolves
|
|
87
|
+ * with false otherwise.
|
108
|
88
|
*/
|
109
|
89
|
export function openDesktopApp() {
|
110
|
|
- windowLoadedPromise.then(() => {
|
111
|
|
- // If the code for opening the deep link is executed before the window
|
112
|
|
- // load event, something with the internal chrome state goes wrong. The
|
113
|
|
- // result is that no window load event is received which is the cause
|
114
|
|
- // for some permission prompts to not be displayed. In our case the GUM
|
115
|
|
- // prompt wasn't displayed which causes the GUM call to never finish.
|
116
|
|
- window.location.href = generateDeepLinkingURL();
|
117
|
|
- });
|
|
90
|
+ return _openDesktopApp();
|
118
|
91
|
}
|