Переглянути джерело

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

master
Hristo Terezov 6 роки тому
джерело
коміт
840c0190c4

+ 1
- 14
react/features/deep-linking/components/DeepLinkingDesktopPage.web.js Переглянути файл

50
         super(props);
50
         super(props);
51
 
51
 
52
         // Bind event handlers so they are only bound once per instance.
52
         // Bind event handlers so they are only bound once per instance.
53
-        this._openDesktopApp = this._openDesktopApp.bind(this);
54
         this._onLaunchWeb = this._onLaunchWeb.bind(this);
53
         this._onLaunchWeb = this._onLaunchWeb.bind(this);
55
         this._onTryAgain = this._onTryAgain.bind(this);
54
         this._onTryAgain = this._onTryAgain.bind(this);
56
     }
55
     }
61
      * @inheritdoc
60
      * @inheritdoc
62
      */
61
      */
63
     componentDidMount() {
62
     componentDidMount() {
64
-        this._openDesktopApp();
65
         sendAnalytics(
63
         sendAnalytics(
66
             createDeepLinkingPageEvent(
64
             createDeepLinkingPageEvent(
67
                 'displayed', 'DeepLinkingDesktop', { isMobileBrowser: false }));
65
                 'displayed', 'DeepLinkingDesktop', { isMobileBrowser: false }));
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
     _onTryAgain: () => {}
134
     _onTryAgain: () => {}
148
 
135
 
149
     /**
136
     /**
155
         sendAnalytics(
142
         sendAnalytics(
156
             createDeepLinkingPageEvent(
143
             createDeepLinkingPageEvent(
157
                 'clicked', 'tryAgainButton', { isMobileBrowser: false }));
144
                 'clicked', 'tryAgainButton', { isMobileBrowser: false }));
158
-        this._openDesktopApp();
145
+        this.props.dispatch(openDesktopApp());
159
     }
146
     }
160
 
147
 
161
     _onLaunchWeb: () => {}
148
     _onLaunchWeb: () => {}

+ 6
- 33
react/features/deep-linking/functions.js Переглянути файл

8
     DeepLinkingMobilePage,
8
     DeepLinkingMobilePage,
9
     NoMobileApp
9
     NoMobileApp
10
 } from './components';
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
  * Generates a deep linking URL based on the current window URL.
14
  * Generates a deep linking URL based on the current window URL.
96
         return Promise.resolve();
75
         return Promise.resolve();
97
     }
76
     }
98
 
77
 
99
-    return _shouldShowDeepLinkingDesktopPage().then(
78
+    return _openDesktopApp().then(
100
         // eslint-disable-next-line no-confusing-arrow
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
  * Opens the desktop app.
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
 export function openDesktopApp() {
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 Переглянути файл

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 Переглянути файл

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

Завантаження…
Відмінити
Зберегти