|
@@ -1,10 +1,17 @@
|
1
|
|
-/* global APP, loggingConfig */
|
|
1
|
+/* @flow */
|
|
2
|
+
|
|
3
|
+import Logger from 'jitsi-meet-logger';
|
2
|
4
|
|
3
|
5
|
import { isRoomValid } from '../base/conference';
|
4
|
6
|
import JitsiMeetJS from '../base/lib-jitsi-meet';
|
5
|
|
-import { RouteRegistry } from '../base/react';
|
6
|
|
-import { interceptComponent } from '../base/util';
|
|
7
|
+import { Platform, RouteRegistry } from '../base/react';
|
7
|
8
|
import { Conference } from '../conference';
|
|
9
|
+import {
|
|
10
|
+ NoMobileApp,
|
|
11
|
+ PluginRequiredBrowser,
|
|
12
|
+ UnsupportedDesktopBrowser,
|
|
13
|
+ UnsupportedMobileBrowser
|
|
14
|
+} from '../unsupported-browser';
|
8
|
15
|
import { WelcomePage } from '../welcome';
|
9
|
16
|
|
10
|
17
|
import URLProcessor from '../../../modules/config/URLProcessor';
|
|
@@ -13,7 +20,65 @@ import KeyboardShortcut
|
13
|
20
|
import getTokenData from '../../../modules/tokendata/TokenData';
|
14
|
21
|
import JitsiMeetLogStorage from '../../../modules/util/JitsiMeetLogStorage';
|
15
|
22
|
|
16
|
|
-const Logger = require('jitsi-meet-logger');
|
|
23
|
+declare var APP: Object;
|
|
24
|
+declare var interfaceConfig: Object;
|
|
25
|
+declare var loggingConfig: Object;
|
|
26
|
+
|
|
27
|
+/**
|
|
28
|
+ * Array of rules defining whether we should {@link _interceptComponent} to
|
|
29
|
+ * render.
|
|
30
|
+ *
|
|
31
|
+ * @private
|
|
32
|
+ * @param {Object} state - Object containing current Redux state.
|
|
33
|
+ * @returns {ReactElement|void}
|
|
34
|
+ * @type {Function[]}
|
|
35
|
+ */
|
|
36
|
+const _INTERCEPT_COMPONENT_RULES = [
|
|
37
|
+
|
|
38
|
+ /**
|
|
39
|
+ * This rule describes case when user opens application using mobile
|
|
40
|
+ * browser. In order to promote the app, we choose to suggest the mobile
|
|
41
|
+ * app even if the browser supports the app (e.g. Google Chrome with
|
|
42
|
+ * WebRTC support on Android).
|
|
43
|
+ *
|
|
44
|
+ * @param {Object} state - Redux state of the app.
|
|
45
|
+ * @returns {UnsupportedMobileBrowser|void} If the rule is satisfied then
|
|
46
|
+ * we should intercept existing component by UnsupportedMobileBrowser.
|
|
47
|
+ */
|
|
48
|
+ () => {
|
|
49
|
+ const OS = Platform.OS;
|
|
50
|
+
|
|
51
|
+ if (OS === 'android' || OS === 'ios') {
|
|
52
|
+ const mobileAppPromo
|
|
53
|
+ = typeof interfaceConfig === 'object'
|
|
54
|
+ && interfaceConfig.MOBILE_APP_PROMO;
|
|
55
|
+
|
|
56
|
+ return (
|
|
57
|
+ typeof mobileAppPromo === 'undefined' || Boolean(mobileAppPromo)
|
|
58
|
+ ? UnsupportedMobileBrowser
|
|
59
|
+ : NoMobileApp);
|
|
60
|
+ }
|
|
61
|
+ },
|
|
62
|
+ state => {
|
|
63
|
+ const { webRTCReady } = state['features/base/lib-jitsi-meet'];
|
|
64
|
+
|
|
65
|
+ switch (typeof webRTCReady) {
|
|
66
|
+ case 'boolean':
|
|
67
|
+ if (webRTCReady === false) {
|
|
68
|
+ return UnsupportedDesktopBrowser;
|
|
69
|
+ }
|
|
70
|
+ break;
|
|
71
|
+
|
|
72
|
+ case 'undefined':
|
|
73
|
+ // If webRTCReady is not set, then we cannot use it to take a
|
|
74
|
+ // decision.
|
|
75
|
+ break;
|
|
76
|
+
|
|
77
|
+ default:
|
|
78
|
+ return PluginRequiredBrowser;
|
|
79
|
+ }
|
|
80
|
+ }
|
|
81
|
+];
|
17
|
82
|
|
18
|
83
|
export { _parseURIString } from './functions.native';
|
19
|
84
|
|
|
@@ -25,7 +90,7 @@ export { _parseURIString } from './functions.native';
|
25
|
90
|
* method.
|
26
|
91
|
* @returns {Route}
|
27
|
92
|
*/
|
28
|
|
-export function _getRouteToRender(stateOrGetState) {
|
|
93
|
+export function _getRouteToRender(stateOrGetState: Object | Function) {
|
29
|
94
|
const state
|
30
|
95
|
= typeof stateOrGetState === 'function'
|
31
|
96
|
? stateOrGetState()
|
|
@@ -38,7 +103,7 @@ export function _getRouteToRender(stateOrGetState) {
|
38
|
103
|
|
39
|
104
|
// Intercepts route components if any of component interceptor rules
|
40
|
105
|
// is satisfied.
|
41
|
|
- route.component = interceptComponent(state, component);
|
|
106
|
+ route.component = _interceptComponent(state, component);
|
42
|
107
|
|
43
|
108
|
return route;
|
44
|
109
|
}
|
|
@@ -118,3 +183,32 @@ function _initLogging() {
|
118
|
183
|
JitsiMeetJS.addGlobalLogTransport(APP.logCollector);
|
119
|
184
|
}
|
120
|
185
|
}
|
|
186
|
+
|
|
187
|
+/**
|
|
188
|
+ * Intercepts route components based on a {@link _INTERCEPT_COMPONENT_RULES}.
|
|
189
|
+ *
|
|
190
|
+ * @param {Object|Function} stateOrGetState - Either Redux state object or
|
|
191
|
+ * getState() function.
|
|
192
|
+ * @param {ReactElement} component - Current route component to render.
|
|
193
|
+ * @private
|
|
194
|
+ * @returns {ReactElement} If any of the pre-defined rules is satisfied, returns
|
|
195
|
+ * intercepted component.
|
|
196
|
+ */
|
|
197
|
+function _interceptComponent(
|
|
198
|
+ stateOrGetState: Object,
|
|
199
|
+ component: ReactElement<*>) {
|
|
200
|
+ let result;
|
|
201
|
+ const state
|
|
202
|
+ = typeof stateOrGetState === 'function'
|
|
203
|
+ ? stateOrGetState()
|
|
204
|
+ : stateOrGetState;
|
|
205
|
+
|
|
206
|
+ for (const rule of _INTERCEPT_COMPONENT_RULES) {
|
|
207
|
+ result = rule(state);
|
|
208
|
+ if (result) {
|
|
209
|
+ break;
|
|
210
|
+ }
|
|
211
|
+ }
|
|
212
|
+
|
|
213
|
+ return result || component;
|
|
214
|
+}
|