瀏覽代碼

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

j8
hristoterezov 6 年之前
父節點
當前提交
12dda7acb9
共有 1 個檔案被更改,包括 46 行新增1 行删除
  1. 46
    1
      react/features/deep-linking/functions.js

+ 46
- 1
react/features/deep-linking/functions.js 查看文件

11
 import { _shouldShowDeepLinkingDesktopPage }
11
 import { _shouldShowDeepLinkingDesktopPage }
12
     from './shouldShowDeepLinkingDesktopPage';
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
  * Generates a deep linking URL based on the current window URL.
53
  * Generates a deep linking URL based on the current window URL.
16
  *
54
  *
76
  * @returns {void}
114
  * @returns {void}
77
  */
115
  */
78
 export function openDesktopApp() {
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
 }

Loading…
取消
儲存