Bläddra i källkod

fix(deep-linking): Don't rely on custom scheme

master
Hristo Terezov 6 år sedan
förälder
incheckning
840c0190c4

+ 1
- 14
react/features/deep-linking/components/DeepLinkingDesktopPage.web.js Visa fil

@@ -50,7 +50,6 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
50 50
         super(props);
51 51
 
52 52
         // Bind event handlers so they are only bound once per instance.
53
-        this._openDesktopApp = this._openDesktopApp.bind(this);
54 53
         this._onLaunchWeb = this._onLaunchWeb.bind(this);
55 54
         this._onTryAgain = this._onTryAgain.bind(this);
56 55
     }
@@ -61,7 +60,6 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
61 60
      * @inheritdoc
62 61
      */
63 62
     componentDidMount() {
64
-        this._openDesktopApp();
65 63
         sendAnalytics(
66 64
             createDeepLinkingPageEvent(
67 65
                 'displayed', 'DeepLinkingDesktop', { isMobileBrowser: false }));
@@ -133,17 +131,6 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
133 131
         );
134 132
     }
135 133
 
136
-    _openDesktopApp: () => {}
137
-
138
-    /**
139
-     * Dispatches the <tt>openDesktopApp</tt> action.
140
-     *
141
-     * @returns {void}
142
-     */
143
-    _openDesktopApp() {
144
-        this.props.dispatch(openDesktopApp());
145
-    }
146
-
147 134
     _onTryAgain: () => {}
148 135
 
149 136
     /**
@@ -155,7 +142,7 @@ class DeepLinkingDesktopPage<P : Props> extends Component<P> {
155 142
         sendAnalytics(
156 143
             createDeepLinkingPageEvent(
157 144
                 'clicked', 'tryAgainButton', { isMobileBrowser: false }));
158
-        this._openDesktopApp();
145
+        this.props.dispatch(openDesktopApp());
159 146
     }
160 147
 
161 148
     _onLaunchWeb: () => {}

+ 6
- 33
react/features/deep-linking/functions.js Visa fil

@@ -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
 }

+ 9
- 0
react/features/deep-linking/openDesktopApp.js Visa fil

@@ -0,0 +1,9 @@
1
+/**
2
+ * Opens the desktop app.
3
+ *
4
+ * @returns {Promise<boolean>} - Resolves with true if the attempt to open the desktop app was successful and resolves
5
+ * with false otherwise.
6
+ */
7
+export function _openDesktopApp() {
8
+    return Promise.resolve(false);
9
+}

+ 0
- 9
react/features/deep-linking/shouldShowDeepLinkingDesktopPage.js Visa fil

@@ -1,9 +0,0 @@
1
-/**
2
- * Resolves with <tt>true</tt> if the deep linking page should be shown and with
3
- * <tt>false</tt> otherwise.
4
- *
5
- * @returns {Promise<boolean>}
6
- */
7
-export function _shouldShowDeepLinkingDesktopPage() {
8
-    return Promise.resolve(false);
9
-}

Laddar…
Avbryt
Spara