瀏覽代碼

core: refactor routing (continued)

master
Lyubo Marinov 7 年之前
父節點
當前提交
c203215c54

+ 10
- 11
conference.js 查看文件

@@ -2320,13 +2320,14 @@ export default {
2320 2320
      * @private
2321 2321
      */
2322 2322
     _initDeviceList() {
2323
-        if (JitsiMeetJS.mediaDevices.isDeviceListAvailable()
2324
-                && JitsiMeetJS.mediaDevices.isDeviceChangeAvailable()) {
2325
-            JitsiMeetJS.mediaDevices.enumerateDevices(devices => {
2326
-                // Ugly way to synchronize real device IDs with local
2327
-                // storage and settings menu. This is a workaround until
2328
-                // getConstraints() method will be implemented
2329
-                // in browsers.
2323
+        const { mediaDevices } = JitsiMeetJS;
2324
+
2325
+        if (mediaDevices.isDeviceListAvailable()
2326
+                && mediaDevices.isDeviceChangeAvailable()) {
2327
+            mediaDevices.enumerateDevices(devices => {
2328
+                // Ugly way to synchronize real device IDs with local storage
2329
+                // and settings menu. This is a workaround until
2330
+                // getConstraints() method will be implemented in browsers.
2330 2331
                 const { dispatch } = APP.store;
2331 2332
 
2332 2333
                 if (this.localAudio) {
@@ -2334,7 +2335,6 @@ export default {
2334 2335
                         micDeviceId: this.localAudio.getDeviceId()
2335 2336
                     }));
2336 2337
                 }
2337
-
2338 2338
                 if (this.localVideo) {
2339 2339
                     dispatch(updateSettings({
2340 2340
                         cameraDeviceId: this.localVideo.getDeviceId()
@@ -2347,9 +2347,8 @@ export default {
2347 2347
             });
2348 2348
 
2349 2349
             this.deviceChangeListener = devices =>
2350
-                window.setTimeout(
2351
-                    () => this._onDeviceListChanged(devices), 0);
2352
-            JitsiMeetJS.mediaDevices.addEventListener(
2350
+                window.setTimeout(() => this._onDeviceListChanged(devices), 0);
2351
+            mediaDevices.addEventListener(
2353 2352
                 JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED,
2354 2353
                 this.deviceChangeListener);
2355 2354
         }

+ 6
- 6
react/features/app/actions.js 查看文件

@@ -78,10 +78,10 @@ function _appNavigateToMandatoryLocation(
78 78
      */
79 79
     function loadConfigSettled(error, config) {
80 80
         // Due to the asynchronous nature of the loading, the specified config
81
-        // may or may not be required by the time the notification arrives.
82
-        // If we receive the config for a location we are no longer interested
83
-        // in, "ignore" it - deliver it to the external API, for example, but do
84
-        // not proceed with the appNavigate procedure/process.
81
+        // may or may not be required by the time the notification arrives. If
82
+        // we receive the config for a location we are no longer interested in,
83
+        // "ignore" it - deliver it to the external API, for example, but do not
84
+        // proceed with the appNavigate procedure/process.
85 85
         if (getState()['features/base/config'].locationURL === locationURL) {
86 86
             dispatch(setLocationURL(locationURL));
87 87
             dispatch(setConfig(config));
@@ -90,8 +90,8 @@ function _appNavigateToMandatoryLocation(
90 90
             error || (error = new Error('Config no longer needed!'));
91 91
 
92 92
             // XXX The failure could be, for example, because of a
93
-            // certificate-related error. In which case the connection will
94
-            // fail later in Strophe anyway.
93
+            // certificate-related error. In which case the connection will fail
94
+            // later in Strophe anyway.
95 95
             dispatch(loadConfigError(error, locationURL));
96 96
 
97 97
             throw error;

+ 11
- 14
react/features/app/components/AbstractApp.js 查看文件

@@ -23,8 +23,8 @@ import { OverlayContainer } from '../../overlay';
23 23
 import { appNavigate, appWillMount, appWillUnmount } from '../actions';
24 24
 
25 25
 /**
26
- * The default URL to open if no other was specified to {@code AbstractApp}
27
- * via props.
26
+ * The default URL to open if no other was specified to {@code AbstractApp} via
27
+ * props.
28 28
  *
29 29
  * FIXME: This is not at the best place here. This should be either in the
30 30
  * base/settings feature or a default in base/config.
@@ -78,6 +78,12 @@ export class AbstractApp extends Component {
78 78
 
79 79
         this.state = {
80 80
 
81
+            /**
82
+             * The state of the »possible« async initialization of
83
+             * the {@code AbstractApp}.
84
+             */
85
+            appAsyncInitialized: false,
86
+
81 87
             /**
82 88
              * The Route rendered by this {@code AbstractApp}.
83 89
              *
@@ -85,12 +91,6 @@ export class AbstractApp extends Component {
85 91
              */
86 92
             route: {},
87 93
 
88
-            /**
89
-             * The state of the »possible« async initialization of
90
-             * the {@code AbstractApp}.
91
-             */
92
-            appAsyncInitialized: false,
93
-
94 94
             /**
95 95
              * The redux store used by this {@code AbstractApp}.
96 96
              *
@@ -239,8 +239,7 @@ export class AbstractApp extends Component {
239 239
      * @returns {ReactElement}
240 240
      */
241 241
     render() {
242
-        const { appAsyncInitialized, route } = this.state;
243
-        const { component } = route;
242
+        const { appAsyncInitialized, route: { component } } = this.state;
244 243
 
245 244
         if (appAsyncInitialized && component) {
246 245
             return (
@@ -357,7 +356,7 @@ export class AbstractApp extends Component {
357 356
         return (
358 357
             this.props.defaultURL
359 358
                 || this._getStore().getState()['features/base/settings']
360
-                .serverURL
359
+                    .serverURL
361 360
                 || DEFAULT_URL);
362 361
     }
363 362
 
@@ -435,9 +434,7 @@ export class AbstractApp extends Component {
435 434
         // performed before setState completes, the app may not navigate to the
436 435
         // expected route. In order to mitigate the problem, _navigate was
437 436
         // changed to return a Promise.
438
-        return new Promise(resolve => {
439
-            this.setState({ route }, resolve);
440
-        });
437
+        return new Promise(resolve => this.setState({ route }, resolve));
441 438
     }
442 439
 
443 440
     /**

+ 0
- 1
react/features/app/functions.native.js 查看文件

@@ -3,7 +3,6 @@
3 3
 import { NativeModules } from 'react-native';
4 4
 
5 5
 export * from './functions.any';
6
-export * from './router';
7 6
 
8 7
 /**
9 8
  * Returns application name.

+ 0
- 1
react/features/app/functions.web.js 查看文件

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3 3
 export * from './functions.any';
4
-export * from './router';
5 4
 
6 5
 declare var interfaceConfig: Object;
7 6
 

react/features/app/router.js → react/features/app/getRouteToRender.js 查看文件

@@ -1,4 +1,5 @@
1 1
 // @flow
2
+
2 3
 import type { Component } from 'react';
3 4
 
4 5
 import { isRoomValid } from '../base/conference';
@@ -35,11 +36,11 @@ export type Route = {
35 36
  * Determines which route is to be rendered in order to depict a specific Redux
36 37
  * store.
37 38
  *
38
- * @param {(Object|Function)} stateful - Redux state or Regux getState()
39
- * method.
39
+ * @param {(Function|Object)} stateful - THe redux store, state, or
40
+ * {@code getState} function.
40 41
  * @returns {Promise<Route>}
41 42
  */
42
-export function getRouteToRender(stateful: Object | Function): Promise<Route> {
43
+export function _getRouteToRender(stateful: Function | Object): Promise<Route> {
43 44
     const state = toState(stateful);
44 45
     const { room } = state['features/base/conference'];
45 46
     const isMobileApp = navigator.product === 'ReactNative';
@@ -51,11 +52,11 @@ export function getRouteToRender(stateful: Object | Function): Promise<Route> {
51 52
     };
52 53
 
53 54
     return new Promise(resolve => {
54
-        // First check if the current endpoint supports WebRTC. We are
55
+        // First, check if the current endpoint supports WebRTC. We are
55 56
         // intentionally not performing the check for mobile browsers because:
56
-        //   - the welcome page is mobile ready
57
-        //   - if the URL points to a conference, getDeepLinkingPage will take
58
-        //     care of it
57
+        // - the WelcomePage is mobile ready;
58
+        // - if the URL points to a conference, getDeepLinkingPage will take
59
+        //   care of it.
59 60
         if (!isMobileBrowser && !JitsiMeetJS.isWebRtcSupported()) {
60 61
             route.component = UnsupportedDesktopBrowser;
61 62
             resolve(route);
@@ -70,8 +71,8 @@ export function getRouteToRender(stateful: Object | Function): Promise<Route> {
70 71
             } else {
71 72
                 // Update the location if it doesn't match. This happens when a
72 73
                 // room is joined from the welcome page. The reason for doing
73
-                // this instead of using the history API is that we want to
74
-                // load the config.js which takes the room into account.
74
+                // this instead of using the history API is that we want to load
75
+                // the config.js which takes the room into account.
75 76
                 const { locationURL } = state['features/base/connection'];
76 77
 
77 78
                 // eslint-disable-next-line no-negated-condition
@@ -91,8 +92,8 @@ export function getRouteToRender(stateful: Object | Function): Promise<Route> {
91 92
         }
92 93
 
93 94
         if (!isWelcomePageUserEnabled(state)) {
94
-            // Web: if the welcome page is disabled, go directly to a
95
-            // random room.
95
+            // Web: if the welcome page is disabled, go directly to a random
96
+            // room.
96 97
 
97 98
             let href = window.location.href;
98 99
 

+ 2
- 2
react/features/app/middleware.js 查看文件

@@ -7,7 +7,7 @@ import {
7 7
 } from '../base/connection';
8 8
 import { MiddlewareRegistry } from '../base/redux';
9 9
 
10
-import { getRouteToRender } from './router';
10
+import { _getRouteToRender } from './getRouteToRender';
11 11
 
12 12
 MiddlewareRegistry.register(store => next => action => {
13 13
     switch (action.type) {
@@ -74,7 +74,7 @@ function _navigate({ getState }) {
74 74
     const state = getState();
75 75
     const { app } = state['features/app'];
76 76
 
77
-    getRouteToRender(state).then(route => app._navigate(route));
77
+    _getRouteToRender(state).then(route => app._navigate(route));
78 78
 }
79 79
 
80 80
 /**

+ 19
- 4
react/features/base/config/functions.js 查看文件

@@ -149,6 +149,24 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
149 149
 export { default as getRoomName } from './getRoomName';
150 150
 export { parseURLParams };
151 151
 
152
+/**
153
+ * Promise wrapper on obtain config method. When HttpConfigFetch will be moved
154
+ * to React app it's better to use load config instead.
155
+ *
156
+ * @param {string} location - URL of the domain from which the config is to be
157
+ * obtained.
158
+ * @param {string} room - Room name.
159
+ * @private
160
+ * @returns {Promise<void>}
161
+ */
162
+export function obtainConfig(location: string, room: string): Promise<void> {
163
+    return new Promise((resolve, reject) =>
164
+        _obtainConfig(location, room, (success, error) => {
165
+            success ? resolve() : reject(error);
166
+        })
167
+    );
168
+}
169
+
152 170
 /**
153 171
  * Sends HTTP POST request to specified {@code endpoint}. In request the name
154 172
  * of the room is included in JSON format:
@@ -163,10 +181,7 @@ export { parseURLParams };
163 181
  * @param {Function} complete - The callback to invoke upon success or failure.
164 182
  * @returns {void}
165 183
  */
166
-export function obtainConfig(
167
-        endpoint: string,
168
-        roomName: string,
169
-        complete: Function) {
184
+function _obtainConfig(endpoint: string, roomName: string, complete: Function) {
170 185
     logger.info(`Send config request to ${endpoint} for room: ${roomName}`);
171 186
     $.ajax(
172 187
         endpoint,

+ 1
- 3
react/features/base/connection/actions.web.js 查看文件

@@ -20,10 +20,8 @@ export {
20 20
  */
21 21
 export function connect() {
22 22
     return (dispatch: Dispatch<*>, getState: Function) => {
23
-        const state = getState();
24
-
25 23
         // XXX Lib-jitsi-meet does not accept uppercase letters.
26
-        const room = state['features/base/conference'].room.toLowerCase();
24
+        const room = getState()['features/base/conference'].room.toLowerCase();
27 25
 
28 26
         // XXX For web based version we use conference initialization logic
29 27
         // from the old app (at the moment of writing).

+ 4
- 7
react/features/conference/components/Conference.native.js 查看文件

@@ -184,8 +184,6 @@ class Conference extends Component<Props> {
184 184
     componentWillReceiveProps(nextProps: Props) {
185 185
         const {
186 186
             _locationURL: oldLocationURL,
187
-            _onConnect,
188
-            _onDisconnect,
189 187
             _participantCount: oldParticipantCount,
190 188
             _room: oldRoom,
191 189
             _setToolboxVisible
@@ -197,10 +195,10 @@ class Conference extends Component<Props> {
197 195
         } = nextProps;
198 196
 
199 197
         // If the location URL changes we need to reconnect.
200
-        oldLocationURL !== newLocationURL && _onDisconnect();
198
+        oldLocationURL !== newLocationURL && this.props._onDisconnect();
201 199
 
202 200
         // Start the connection process when there is a (valid) room.
203
-        oldRoom !== newRoom && newRoom && _onConnect();
201
+        oldRoom !== newRoom && newRoom && this.props._onConnect();
204 202
 
205 203
         if (oldParticipantCount === 1) {
206 204
             newParticipantCount > 1 && _setToolboxVisible(false);
@@ -342,9 +340,7 @@ class Conference extends Component<Props> {
342 340
      * @returns {React$Node}
343 341
      */
344 342
     _renderConferenceNotification() {
345
-        return ConferenceNotification
346
-            ? <ConferenceNotification />
347
-            : undefined;
343
+        return ConferenceNotification ? <ConferenceNotification /> : undefined;
348 344
     }
349 345
 }
350 346
 
@@ -356,6 +352,7 @@ class Conference extends Component<Props> {
356 352
  * @returns {{
357 353
  *     _onConnect: Function,
358 354
  *     _onDisconnect: Function,
355
+ *     _onHardwareBackPress: Function,
359 356
  *     _setToolboxVisible: Function
360 357
  * }}
361 358
  */

+ 5
- 22
react/features/conference/components/Conference.web.js 查看文件

@@ -28,24 +28,6 @@ declare var interfaceConfig: Object;
28 28
 
29 29
 const logger = require('jitsi-meet-logger').getLogger(__filename);
30 30
 
31
-/**
32
- * Promise wrapper on obtain config method. When HttpConfigFetch will be moved
33
- * to React app it's better to use load config instead.
34
- *
35
- * @param {string} location - URL of the domain from which the config is to be
36
- * obtained.
37
- * @param {string} room - Room name.
38
- * @private
39
- * @returns {Promise}
40
- */
41
-function _obtainConfig(location: string, room: string) {
42
-    return new Promise((resolve, reject) =>
43
-        obtainConfig(location, room, (success, error) => {
44
-            success ? resolve() : reject(error);
45
-        })
46
-    );
47
-}
48
-
49 31
 /**
50 32
  * DOM events for when full screen mode has changed. Different browsers need
51 33
  * different vendor prefixes.
@@ -119,7 +101,7 @@ class Conference extends Component<Props> {
119 101
         const { configLocation } = config;
120 102
 
121 103
         if (configLocation) {
122
-            _obtainConfig(configLocation, this.props._room)
104
+            obtainConfig(configLocation, this.props._room)
123 105
                 .then(() => {
124 106
                     const now = window.performance.now();
125 107
 
@@ -133,8 +115,8 @@ class Conference extends Component<Props> {
133 115
 
134 116
                     // Show obtain config error.
135 117
                     APP.UI.messageHandler.showError({
136
-                        titleKey: 'connection.CONNFAIL',
137
-                        descriptionKey: 'dialog.connectError'
118
+                        descriptionKey: 'dialog.connectError',
119
+                        titleKey: 'connection.CONNFAIL'
138 120
                     });
139 121
                 });
140 122
         } else {
@@ -253,7 +235,8 @@ class Conference extends Component<Props> {
253 235
  * @param {Object} state - The Redux state.
254 236
  * @private
255 237
  * @returns {{
256
- *     _iAmRecorder: boolean
238
+ *     _iAmRecorder: boolean,
239
+ *     _room: ?string
257 240
  * }}
258 241
  */
259 242
 function _mapStateToProps(state) {

+ 2
- 2
react/features/welcome/components/BlankPage.native.js 查看文件

@@ -10,11 +10,11 @@ import { NetworkActivityIndicator } from '../../mobile/network-activity';
10 10
 import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
11 11
 
12 12
 /**
13
- * {@code BlankPage} React {@code Component}'s prop types.
13
+ * The type of React {@code Component} props of {@link BlankPage}.
14 14
  */
15 15
 type Props = {
16 16
     dispatch: Dispatch<*>
17
-}
17
+};
18 18
 
19 19
 /**
20 20
  * The React {@code Component} displayed by {@code AbstractApp} when it has no

Loading…
取消
儲存