Browse Source

core: refactor routing (continued)

master
Lyubo Marinov 7 years ago
parent
commit
c203215c54

+ 10
- 11
conference.js View File

2320
      * @private
2320
      * @private
2321
      */
2321
      */
2322
     _initDeviceList() {
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
                 const { dispatch } = APP.store;
2331
                 const { dispatch } = APP.store;
2331
 
2332
 
2332
                 if (this.localAudio) {
2333
                 if (this.localAudio) {
2334
                         micDeviceId: this.localAudio.getDeviceId()
2335
                         micDeviceId: this.localAudio.getDeviceId()
2335
                     }));
2336
                     }));
2336
                 }
2337
                 }
2337
-
2338
                 if (this.localVideo) {
2338
                 if (this.localVideo) {
2339
                     dispatch(updateSettings({
2339
                     dispatch(updateSettings({
2340
                         cameraDeviceId: this.localVideo.getDeviceId()
2340
                         cameraDeviceId: this.localVideo.getDeviceId()
2347
             });
2347
             });
2348
 
2348
 
2349
             this.deviceChangeListener = devices =>
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
                 JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED,
2352
                 JitsiMediaDevicesEvents.DEVICE_LIST_CHANGED,
2354
                 this.deviceChangeListener);
2353
                 this.deviceChangeListener);
2355
         }
2354
         }

+ 6
- 6
react/features/app/actions.js View File

78
      */
78
      */
79
     function loadConfigSettled(error, config) {
79
     function loadConfigSettled(error, config) {
80
         // Due to the asynchronous nature of the loading, the specified config
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
         if (getState()['features/base/config'].locationURL === locationURL) {
85
         if (getState()['features/base/config'].locationURL === locationURL) {
86
             dispatch(setLocationURL(locationURL));
86
             dispatch(setLocationURL(locationURL));
87
             dispatch(setConfig(config));
87
             dispatch(setConfig(config));
90
             error || (error = new Error('Config no longer needed!'));
90
             error || (error = new Error('Config no longer needed!'));
91
 
91
 
92
             // XXX The failure could be, for example, because of a
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
             dispatch(loadConfigError(error, locationURL));
95
             dispatch(loadConfigError(error, locationURL));
96
 
96
 
97
             throw error;
97
             throw error;

+ 11
- 14
react/features/app/components/AbstractApp.js View File

23
 import { appNavigate, appWillMount, appWillUnmount } from '../actions';
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
  * FIXME: This is not at the best place here. This should be either in the
29
  * FIXME: This is not at the best place here. This should be either in the
30
  * base/settings feature or a default in base/config.
30
  * base/settings feature or a default in base/config.
78
 
78
 
79
         this.state = {
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
              * The Route rendered by this {@code AbstractApp}.
88
              * The Route rendered by this {@code AbstractApp}.
83
              *
89
              *
85
              */
91
              */
86
             route: {},
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
              * The redux store used by this {@code AbstractApp}.
95
              * The redux store used by this {@code AbstractApp}.
96
              *
96
              *
239
      * @returns {ReactElement}
239
      * @returns {ReactElement}
240
      */
240
      */
241
     render() {
241
     render() {
242
-        const { appAsyncInitialized, route } = this.state;
243
-        const { component } = route;
242
+        const { appAsyncInitialized, route: { component } } = this.state;
244
 
243
 
245
         if (appAsyncInitialized && component) {
244
         if (appAsyncInitialized && component) {
246
             return (
245
             return (
357
         return (
356
         return (
358
             this.props.defaultURL
357
             this.props.defaultURL
359
                 || this._getStore().getState()['features/base/settings']
358
                 || this._getStore().getState()['features/base/settings']
360
-                .serverURL
359
+                    .serverURL
361
                 || DEFAULT_URL);
360
                 || DEFAULT_URL);
362
     }
361
     }
363
 
362
 
435
         // performed before setState completes, the app may not navigate to the
434
         // performed before setState completes, the app may not navigate to the
436
         // expected route. In order to mitigate the problem, _navigate was
435
         // expected route. In order to mitigate the problem, _navigate was
437
         // changed to return a Promise.
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 View File

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

+ 0
- 1
react/features/app/functions.web.js View File

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

react/features/app/router.js → react/features/app/getRouteToRender.js View File

1
 // @flow
1
 // @flow
2
+
2
 import type { Component } from 'react';
3
 import type { Component } from 'react';
3
 
4
 
4
 import { isRoomValid } from '../base/conference';
5
 import { isRoomValid } from '../base/conference';
35
  * Determines which route is to be rendered in order to depict a specific Redux
36
  * Determines which route is to be rendered in order to depict a specific Redux
36
  * store.
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
  * @returns {Promise<Route>}
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
     const state = toState(stateful);
44
     const state = toState(stateful);
44
     const { room } = state['features/base/conference'];
45
     const { room } = state['features/base/conference'];
45
     const isMobileApp = navigator.product === 'ReactNative';
46
     const isMobileApp = navigator.product === 'ReactNative';
51
     };
52
     };
52
 
53
 
53
     return new Promise(resolve => {
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
         // intentionally not performing the check for mobile browsers because:
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
         if (!isMobileBrowser && !JitsiMeetJS.isWebRtcSupported()) {
60
         if (!isMobileBrowser && !JitsiMeetJS.isWebRtcSupported()) {
60
             route.component = UnsupportedDesktopBrowser;
61
             route.component = UnsupportedDesktopBrowser;
61
             resolve(route);
62
             resolve(route);
70
             } else {
71
             } else {
71
                 // Update the location if it doesn't match. This happens when a
72
                 // Update the location if it doesn't match. This happens when a
72
                 // room is joined from the welcome page. The reason for doing
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
                 const { locationURL } = state['features/base/connection'];
76
                 const { locationURL } = state['features/base/connection'];
76
 
77
 
77
                 // eslint-disable-next-line no-negated-condition
78
                 // eslint-disable-next-line no-negated-condition
91
         }
92
         }
92
 
93
 
93
         if (!isWelcomePageUserEnabled(state)) {
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
             let href = window.location.href;
98
             let href = window.location.href;
98
 
99
 

+ 2
- 2
react/features/app/middleware.js View File

7
 } from '../base/connection';
7
 } from '../base/connection';
8
 import { MiddlewareRegistry } from '../base/redux';
8
 import { MiddlewareRegistry } from '../base/redux';
9
 
9
 
10
-import { getRouteToRender } from './router';
10
+import { _getRouteToRender } from './getRouteToRender';
11
 
11
 
12
 MiddlewareRegistry.register(store => next => action => {
12
 MiddlewareRegistry.register(store => next => action => {
13
     switch (action.type) {
13
     switch (action.type) {
74
     const state = getState();
74
     const state = getState();
75
     const { app } = state['features/app'];
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 View File

149
 export { default as getRoomName } from './getRoomName';
149
 export { default as getRoomName } from './getRoomName';
150
 export { parseURLParams };
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
  * Sends HTTP POST request to specified {@code endpoint}. In request the name
171
  * Sends HTTP POST request to specified {@code endpoint}. In request the name
154
  * of the room is included in JSON format:
172
  * of the room is included in JSON format:
163
  * @param {Function} complete - The callback to invoke upon success or failure.
181
  * @param {Function} complete - The callback to invoke upon success or failure.
164
  * @returns {void}
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
     logger.info(`Send config request to ${endpoint} for room: ${roomName}`);
185
     logger.info(`Send config request to ${endpoint} for room: ${roomName}`);
171
     $.ajax(
186
     $.ajax(
172
         endpoint,
187
         endpoint,

+ 1
- 3
react/features/base/connection/actions.web.js View File

20
  */
20
  */
21
 export function connect() {
21
 export function connect() {
22
     return (dispatch: Dispatch<*>, getState: Function) => {
22
     return (dispatch: Dispatch<*>, getState: Function) => {
23
-        const state = getState();
24
-
25
         // XXX Lib-jitsi-meet does not accept uppercase letters.
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
         // XXX For web based version we use conference initialization logic
26
         // XXX For web based version we use conference initialization logic
29
         // from the old app (at the moment of writing).
27
         // from the old app (at the moment of writing).

+ 4
- 7
react/features/conference/components/Conference.native.js View File

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

+ 5
- 22
react/features/conference/components/Conference.web.js View File

28
 
28
 
29
 const logger = require('jitsi-meet-logger').getLogger(__filename);
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
  * DOM events for when full screen mode has changed. Different browsers need
32
  * DOM events for when full screen mode has changed. Different browsers need
51
  * different vendor prefixes.
33
  * different vendor prefixes.
119
         const { configLocation } = config;
101
         const { configLocation } = config;
120
 
102
 
121
         if (configLocation) {
103
         if (configLocation) {
122
-            _obtainConfig(configLocation, this.props._room)
104
+            obtainConfig(configLocation, this.props._room)
123
                 .then(() => {
105
                 .then(() => {
124
                     const now = window.performance.now();
106
                     const now = window.performance.now();
125
 
107
 
133
 
115
 
134
                     // Show obtain config error.
116
                     // Show obtain config error.
135
                     APP.UI.messageHandler.showError({
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
         } else {
122
         } else {
253
  * @param {Object} state - The Redux state.
235
  * @param {Object} state - The Redux state.
254
  * @private
236
  * @private
255
  * @returns {{
237
  * @returns {{
256
- *     _iAmRecorder: boolean
238
+ *     _iAmRecorder: boolean,
239
+ *     _room: ?string
257
  * }}
240
  * }}
258
  */
241
  */
259
 function _mapStateToProps(state) {
242
 function _mapStateToProps(state) {

+ 2
- 2
react/features/welcome/components/BlankPage.native.js View File

10
 import LocalVideoTrackUnderlay from './LocalVideoTrackUnderlay';
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
 type Props = {
15
 type Props = {
16
     dispatch: Dispatch<*>
16
     dispatch: Dispatch<*>
17
-}
17
+};
18
 
18
 
19
 /**
19
 /**
20
  * The React {@code Component} displayed by {@code AbstractApp} when it has no
20
  * The React {@code Component} displayed by {@code AbstractApp} when it has no

Loading…
Cancel
Save