Просмотр исходного кода

fix(deep-linking): GUM when the deep linking page have been displayed.

j8
hristoterezov 6 лет назад
Родитель
Сommit
12dda7acb9
1 измененных файлов: 46 добавлений и 1 удалений
  1. 46
    1
      react/features/deep-linking/functions.js

+ 46
- 1
react/features/deep-linking/functions.js Просмотреть файл

@@ -11,6 +11,44 @@ import {
11 11
 import { _shouldShowDeepLinkingDesktopPage }
12 12
     from './shouldShowDeepLinkingDesktopPage';
13 13
 
14
+/**
15
+ * Indicates whether the window load event was already received.
16
+ *
17
+ * @type {boolean}
18
+ */
19
+let windowIsLoaded = false;
20
+
21
+/**
22
+ * Handler for the window load event.
23
+ *
24
+ * @returns {void}
25
+ */
26
+function onWindowLoad() {
27
+    windowIsLoaded = true;
28
+    window.removeEventListener('load', onWindowLoad);
29
+}
30
+
31
+window.addEventListener('load', onWindowLoad);
32
+
33
+/**
34
+ * Executes the passed function after the window load event was received.
35
+ *
36
+ * @param {Function} fn - The function that will be executed.
37
+ * @returns {void}
38
+ */
39
+function executeAfterWindowLoad(fn) {
40
+    if (windowIsLoaded) {
41
+        fn();
42
+    } else {
43
+        const loadHandler = () => {
44
+            fn();
45
+            window.removeEventListener('load', loadHandler);
46
+        };
47
+
48
+        window.addEventListener('load', loadHandler);
49
+    }
50
+}
51
+
14 52
 /**
15 53
  * Generates a deep linking URL based on the current window URL.
16 54
  *
@@ -76,5 +114,12 @@ export function getDeepLinkingPage(state) {
76 114
  * @returns {void}
77 115
  */
78 116
 export function openDesktopApp() {
79
-    window.location.href = generateDeepLinkingURL();
117
+    executeAfterWindowLoad(() => {
118
+        // If the code for opening the deep link is executed before the window
119
+        // load event, something with the internal chrome state goes wrong. The
120
+        // result is that no window load event is received which is the cause
121
+        // for some permission prompts to not be displayed. In our case the GUM
122
+        // prompt wasn't displayed which causes the GUM call to never finish.
123
+        window.location.href = generateDeepLinkingURL();
124
+    });
80 125
 }

Загрузка…
Отмена
Сохранить