瀏覽代碼

[RN] Simplify

There were getDomain, setDomain, SET_DOMAIN, setRoomURL, SET_ROOM_URL
which together were repeating one and the same information and in the
case of the 'room URL' abstraction was not 100% accurate because it
would exist even when there was no room. Replace them all with a
'location URL' abstraction which exists with or without a room.

Then the 'room URL' abstraction was not used in (mobile) feature
share-room. Use the 'location URL' there now.

Finally, removes source code duplication in supporting the Web
application context root.
j8
Lyubo Marinov 8 年之前
父節點
當前提交
2f3706bd37

+ 3
- 10
conference.js 查看文件

@@ -19,8 +19,7 @@ import analytics from './modules/analytics/analytics';
19 19
 
20 20
 import EventEmitter from "events";
21 21
 
22
-import { showDesktopSharingButton } from './react/features/toolbox';
23
-
22
+import { getLocationContextRoot } from './react/features/app';
24 23
 import {
25 24
     AVATAR_ID_COMMAND,
26 25
     AVATAR_URL_COMMAND,
@@ -50,6 +49,7 @@ import {
50 49
     mediaPermissionPromptVisibilityChanged,
51 50
     suspendDetected
52 51
 } from './react/features/overlay';
52
+import { showDesktopSharingButton } from './react/features/toolbox';
53 53
 
54 54
 const ConnectionEvents = JitsiMeetJS.events.connection;
55 55
 const ConnectionErrors = JitsiMeetJS.errors.connection;
@@ -311,18 +311,11 @@ function assignWindowLocationPathname(pathname) {
311 311
     const windowLocation = window.location;
312 312
 
313 313
     if (!pathname.startsWith('/')) {
314
-        // XXX To support a deployment in a sub-directory, assume that the room
315
-        // (name) is the last non-directory component of the path (name).
316
-        let contextRoot = windowLocation.pathname;
317
-
318
-        contextRoot
319
-            = contextRoot.substring(0, contextRoot.lastIndexOf('/') + 1);
320
-
321 314
         // A pathname equal to ./ specifies the current directory. It will be
322 315
         // fine but pointless to include it because contextRoot is the current
323 316
         // directory.
324 317
         pathname.startsWith('./') && (pathname = pathname.substring(2));
325
-        pathname = contextRoot + pathname;
318
+        pathname = getLocationContextRoot(windowLocation) + pathname;
326 319
     }
327 320
 
328 321
     windowLocation.pathname = pathname;

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

@@ -1,6 +1,6 @@
1
-import { setRoom, setRoomURL } from '../base/conference';
1
+import { setRoom } from '../base/conference';
2
+import { setLocationURL } from '../base/connection';
2 3
 import { setConfig } from '../base/config';
3
-import { getDomain, setDomain } from '../base/connection';
4 4
 import { loadConfig } from '../base/lib-jitsi-meet';
5 5
 
6 6
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from './actionTypes';
@@ -23,100 +23,151 @@ export function appInit() {
23 23
 }
24 24
 
25 25
 /**
26
- * Triggers an in-app navigation to a different route. Allows navigation to be
27
- * abstracted between the mobile and web versions.
26
+ * Triggers an in-app navigation to a specific route. Allows navigation to be
27
+ * abstracted between the mobile/React Native and Web/React applications.
28 28
  *
29 29
  * @param {(string|undefined)} uri - The URI to which to navigate. It may be a
30
- * full URL with an http(s) scheme, a full or partial URI with the app-specific
30
+ * full URL with an HTTP(S) scheme, a full or partial URI with the app-specific
31 31
  * sheme, or a mere room name.
32 32
  * @returns {Function}
33 33
  */
34
-export function appNavigate(uri) {
35
-    return (dispatch: Dispatch<*>, getState: Function) => {
36
-        const state = getState();
37
-        const oldDomain = getDomain(state);
38
-        const defaultURL = state['features/app'].app._getDefaultURL();
39
-        let urlObject;
40
-
41
-        // eslint-disable-next-line prefer-const
42
-        let { domain, room } = _parseURIString(uri);
43
-
44
-        // If the specified URI does not identify a domain, use the app's
45
-        // default.
46
-        if (typeof domain === 'undefined') {
47
-            domain = _parseURIString(defaultURL).domain;
48
-        }
49
-
50
-        if (room) {
51
-            const splitURL = uri.split(domain);
52
-            const urlWithoutDomain = splitURL[splitURL.length - 1];
34
+export function appNavigate(uri: ?string) {
35
+    return (dispatch: Dispatch<*>, getState: Function) =>
36
+        _appNavigateToOptionalLocation(
37
+            dispatch, getState,
38
+            _parseURIString(uri));
39
+}
53 40
 
54
-            urlObject = new URL(urlWithoutDomain, `https://${domain}`);
41
+/**
42
+ * Triggers an in-app navigation to a specific location URI.
43
+ *
44
+ * @param {Dispatch} dispatch - The redux {@code dispatch} function.
45
+ * @param {Function} getState - The redux function that gets/retrieves the redux
46
+ * state.
47
+ * @param {Object} newLocation - The location URI to navigate to. The value
48
+ * cannot be undefined and is assumed to have all properties such as
49
+ * {@code host} and {@code room} defined values.
50
+ * @private
51
+ * @returns {void}
52
+ */
53
+function _appNavigateToMandatoryLocation(
54
+        dispatch: Dispatch<*>, getState: Function,
55
+        newLocation: Object) {
56
+    // TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
57
+    // currently in a conference and ask her if she wants to close the
58
+    // current conference and start a new one with the new room name or
59
+    // domain.
60
+
61
+    const oldLocationURL = getState()['features/base/connection'].locationURL;
62
+    const oldHost = oldLocationURL ? oldLocationURL.host : undefined;
63
+    const newHost = newLocation.host;
64
+
65
+    if (oldHost === newHost) {
66
+        dispatchSetLocationURL();
67
+        dispatchSetRoomAndNavigate();
68
+    } else {
69
+        // If the host has changed, we need to load the config of the new host
70
+        // and set it, and only after that we can navigate to a different route.
71
+        _loadConfig(newLocation)
72
+            .then(
73
+                config => configLoaded(/* err */ undefined, config),
74
+                err => configLoaded(err, /* config */ undefined))
75
+            .then(dispatchSetRoomAndNavigate);
76
+    }
77
+
78
+    /**
79
+     * Notifies that an attempt to load the config(uration) of domain has
80
+     * completed.
81
+     *
82
+     * @param {string|undefined} err - If the loading has failed, the error
83
+     * detailing the cause of the failure.
84
+     * @param {Object|undefined} config - If the loading has succeeded, the
85
+     * loaded config(uration).
86
+     * @returns {void}
87
+     */
88
+    function configLoaded(err, config) {
89
+        if (err) {
90
+            // XXX The failure could be, for example, because of a
91
+            // certificate-related error. In which case the connection will
92
+            // fail later in Strophe anyway even if we use the default
93
+            // config here.
94
+
95
+            // The function loadConfig will log the err.
96
+            return;
55 97
         }
56 98
 
57
-        dispatch(setRoomURL(urlObject));
58
-
59
-        // TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
60
-        // currently in a conference and ask her if she wants to close the
61
-        // current conference and start a new one with the new room name or
62
-        // domain.
63
-
64
-        if (typeof domain === 'undefined' || oldDomain === domain) {
65
-            dispatchSetRoomAndNavigate();
66
-        } else if (oldDomain !== domain) {
67
-            // Update domain without waiting for config to be loaded to prevent
68
-            // race conditions when we will start to load config multiple times.
69
-            dispatch(setDomain(domain));
70
-
71
-            // If domain has changed, we need to load the config of the new
72
-            // domain and set it, and only after that we can navigate to a
73
-            // different route.
74
-            loadConfig(`https://${domain}`)
75
-                .then(
76
-                    config => configLoaded(/* err */ undefined, config),
77
-                    err => configLoaded(err, /* config */ undefined))
78
-                .then(dispatchSetRoomAndNavigate);
79
-        }
99
+        dispatchSetLocationURL();
100
+        dispatch(setConfig(config));
101
+    }
102
+
103
+    /**
104
+     * Dispatches {@link setLocationURL} in the redux store.
105
+     *
106
+     * @returns {void}
107
+     */
108
+    function dispatchSetLocationURL() {
109
+        dispatch(
110
+            setLocationURL(
111
+                new URL(
112
+                    (newLocation.protocol || 'https:')
113
+
114
+                        // TODO userinfo
115
+
116
+                        + newLocation.host
117
+                        + (newLocation.pathname || '/')
118
+                        + newLocation.search
119
+                        + newLocation.hash)));
120
+    }
121
+
122
+    /**
123
+     * Dispatches {@link _setRoomAndNavigate} in the redux store.
124
+     *
125
+     * @returns {void}
126
+     */
127
+    function dispatchSetRoomAndNavigate() {
128
+        dispatch(_setRoomAndNavigate(newLocation.room));
129
+    }
130
+}
80 131
 
81
-        /**
82
-         * Notifies that an attempt to load the config(uration) of domain has
83
-         * completed.
84
-         *
85
-         * @param {string|undefined} err - If the loading has failed, the error
86
-         * detailing the cause of the failure.
87
-         * @param {Object|undefined} config - If the loading has succeeded, the
88
-         * loaded config(uration).
89
-         * @returns {void}
90
-         */
91
-        function configLoaded(err, config) {
92
-            if (err) {
93
-                // XXX The failure could be, for example, because of a
94
-                // certificate-related error. In which case the connection will
95
-                // fail later in Strophe anyway even if we use the default
96
-                // config here.
97
-
98
-                // The function loadConfig will log the err.
99
-                return;
100
-            }
101
-
102
-            dispatch(setConfig(config));
132
+/**
133
+ * Triggers an in-app navigation to a specific or undefined location (URI).
134
+ *
135
+ * @param {Dispatch} dispatch - The redux {@code dispatch} function.
136
+ * @param {Function} getState - The redux function that gets/retrieves the redux
137
+ * state.
138
+ * @param {Object} location - The location (URI) to navigate to. The value may
139
+ * be undefined.
140
+ * @private
141
+ * @returns {void}
142
+ */
143
+function _appNavigateToOptionalLocation(
144
+        dispatch: Dispatch<*>, getState: Function,
145
+        location: Object) {
146
+    // If the specified location (URI) does not identify a host, use the app's
147
+    // default.
148
+    if (!location || !location.host) {
149
+        const defaultLocation
150
+            = _parseURIString(getState()['features/app'].app._getDefaultURL());
151
+
152
+        if (location) {
153
+            location.host = defaultLocation.host;
154
+
155
+            // FIXME Turn location's host, hostname, and port properties into
156
+            // setters in order to reduce the risks of inconsistent state.
157
+            location.hostname = defaultLocation.hostname;
158
+            location.port = defaultLocation.port;
159
+            location.protocol = defaultLocation.protocol;
160
+        } else {
161
+            // eslint-disable-next-line no-param-reassign
162
+            location = defaultLocation;
103 163
         }
164
+    }
104 165
 
105
-        /**
106
-         * Dispatches _setRoomAndNavigate in the Redux store.
107
-         *
108
-         * @returns {void}
109
-         */
110
-        function dispatchSetRoomAndNavigate() {
111
-            // If both domain and room vars became undefined, that means we're
112
-            // actually dealing with just room name and not with URL.
113
-            dispatch(
114
-                _setRoomAndNavigate(
115
-                    typeof room === 'undefined' && typeof domain === 'undefined'
116
-                        ? uri
117
-                        : room));
118
-        }
119
-    };
166
+    if (!location.protocol) {
167
+        location.protocol = 'https:';
168
+    }
169
+
170
+    _appNavigateToMandatoryLocation(dispatch, getState, location);
120 171
 }
121 172
 
122 173
 /**
@@ -151,6 +202,27 @@ export function appWillUnmount(app) {
151 202
     };
152 203
 }
153 204
 
205
+/**
206
+ * Loads config.js from a specific host.
207
+ *
208
+ * @param {Object} location - The loction URI which specifies the host to load
209
+ * the config.js from.
210
+ * @returns {Promise<Object>}
211
+ */
212
+function _loadConfig(location: Object) {
213
+    let protocol = location.protocol.toLowerCase();
214
+
215
+    // The React Native app supports an app-specific scheme which is sure to not
216
+    // be supported by fetch (or whatever loadConfig utilizes).
217
+    if (protocol !== 'http:' && protocol !== 'https:') {
218
+        protocol = 'https:';
219
+    }
220
+
221
+    // TDOO userinfo
222
+
223
+    return loadConfig(protocol + location.host + (location.contextRoot || '/'));
224
+}
225
+
154 226
 /**
155 227
  * Navigates to a route in accord with a specific Redux state.
156 228
  *

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

@@ -268,13 +268,13 @@ export class AbstractApp extends Component {
268 268
         // By default, open the domain configured in the configuration file
269 269
         // which may be the domain at which the whole server infrastructure is
270 270
         // deployed.
271
-        const config = this.props.config;
271
+        const { config } = this.props;
272 272
 
273 273
         if (typeof config === 'object') {
274
-            const hosts = config.hosts;
274
+            const { hosts } = config;
275 275
 
276 276
             if (typeof hosts === 'object') {
277
-                const domain = hosts.domain;
277
+                const { domain } = hosts;
278 278
 
279 279
                 if (domain) {
280 280
                     return `https://${domain}`;

+ 2
- 7
react/features/app/components/App.web.js 查看文件

@@ -1,5 +1,6 @@
1 1
 import { appInit } from '../actions';
2 2
 import { AbstractApp } from './AbstractApp';
3
+import { getLocationContextRoot } from '../functions';
3 4
 
4 5
 import '../../room-lock';
5 6
 
@@ -65,13 +66,7 @@ export class App extends AbstractApp {
65 66
      * @returns {string} The context root of window.location i.e. this Web App.
66 67
      */
67 68
     _getWindowLocationContextRoot() {
68
-        const pathname = this.getWindowLocation().pathname;
69
-        const contextRootEndIndex = pathname.lastIndexOf('/');
70
-
71
-        return (
72
-            contextRootEndIndex === -1
73
-                ? '/'
74
-                : pathname.substring(0, contextRootEndIndex + 1));
69
+        return getLocationContextRoot(this.getWindowLocation());
75 70
     }
76 71
 
77 72
     /**

+ 123
- 80
react/features/app/functions.native.js 查看文件

@@ -112,39 +112,21 @@ function _fixURIStringScheme(uri) {
112 112
 }
113 113
 
114 114
 /**
115
- * Gets room name and domain from URL object.
115
+ * Gets the (Web application) context root defined by a specific location (URI).
116 116
  *
117
- * @param {URL} url - URL object.
118
- * @private
119
- * @returns {{
120
- *     domain: (string|undefined),
121
- *     room: (string|undefined)
122
- * }}
117
+ * @param {Object} location - The location (URI) which defines the (Web
118
+ * application) context root.
119
+ * @returns {string} - The (Web application) context root defined by the
120
+ * specified {@code location} (URI).
123 121
  */
124
-function _getRoomAndDomainFromURLObject(url) {
125
-    let domain;
126
-    let room;
127
-
128
-    if (url) {
129
-        domain = url.host;
130
-
131
-        // The room (name) is the last component of pathname.
132
-        room = url.pathname;
133
-        room = room.substring(room.lastIndexOf('/') + 1);
134
-
135
-        // Convert empty string to undefined to simplify checks.
136
-        if (room === '') {
137
-            room = undefined;
138
-        }
139
-        if (domain === '') {
140
-            domain = undefined;
141
-        }
142
-    }
143
-
144
-    return {
145
-        domain,
146
-        room
147
-    };
122
+export function getLocationContextRoot(location: Object) {
123
+    const pathname = location.pathname;
124
+    const contextRootEndIndex = pathname.lastIndexOf('/');
125
+
126
+    return (
127
+        contextRootEndIndex === -1
128
+            ? '/'
129
+            : pathname.substring(0, contextRootEndIndex + 1));
148 130
 }
149 131
 
150 132
 /**
@@ -160,81 +142,142 @@ export function _getRouteToRender(stateOrGetState) {
160 142
         = typeof stateOrGetState === 'function'
161 143
             ? stateOrGetState()
162 144
             : stateOrGetState;
163
-    const room = state['features/base/conference'].room;
145
+    const { room } = state['features/base/conference'];
164 146
     const component = isRoomValid(room) ? Conference : WelcomePage;
165 147
 
166 148
     return RouteRegistry.getRouteByComponent(component);
167 149
 }
168 150
 
169 151
 /**
170
- * Parses a specific URI which (supposedly) references a Jitsi Meet resource
171
- * (location).
152
+ * Parses a specific URI string into an object with the well-known properties of
153
+ * the {@link Location} and/or {@link URL} interfaces implemented by Web
154
+ * browsers. The parsing attempts to be in accord with IETF's RFC 3986.
172 155
  *
173
- * @param {(string|undefined)} uri - The URI to parse which (supposedly)
174
- * references a Jitsi Meet resource (location).
156
+ * @param {string} str - The URI string to parse.
175 157
  * @returns {{
176
- *     domain: (string|undefined),
177
- *     room: (string|undefined)
158
+ *     hash: string,
159
+ *     host: (string|undefined),
160
+ *     hostname: (string|undefined),
161
+ *     pathname: string,
162
+ *     port: (string|undefined),
163
+ *     protocol: (string|undefined),
164
+ *     search: string
178 165
  * }}
179 166
  */
180
-export function _parseURIString(uri) {
181
-    let obj;
167
+function _parseStandardURIString(str: string) {
168
+    /* eslint-disable no-param-reassign */
182 169
 
183
-    if (typeof uri === 'string') {
184
-        let str = uri;
170
+    const obj = {};
171
+
172
+    let regex;
173
+    let match;
174
+
175
+    // protocol
176
+    regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}`, 'gi');
177
+    match = regex.exec(str);
178
+    if (match) {
179
+        obj.protocol = match[1].toLowerCase();
180
+        str = str.substring(regex.lastIndex);
181
+    }
185 182
 
186
-        str = _fixURIStringScheme(str);
187
-        str = _fixURIStringHierPart(str);
183
+    // authority
184
+    regex = new RegExp(`^${_URI_AUTHORITY_PATTERN}`, 'gi');
185
+    match = regex.exec(str);
186
+    if (match) {
187
+        let authority = match[1].substring(/* // */ 2);
188 188
 
189
-        obj = {};
189
+        str = str.substring(regex.lastIndex);
190 190
 
191
-        let regex;
192
-        let match;
191
+        // userinfo
192
+        const userinfoEndIndex = authority.indexOf('@');
193 193
 
194
-        // protocol
195
-        regex = new RegExp(`^${_URI_PROTOCOL_PATTERN}`, 'gi');
196
-        match = regex.exec(str);
197
-        if (match) {
198
-            obj.protocol = match[1].toLowerCase();
199
-            str = str.substring(regex.lastIndex);
194
+        if (userinfoEndIndex !== -1) {
195
+            authority = authority.substring(userinfoEndIndex + 1);
200 196
         }
201 197
 
202
-        // authority
203
-        regex = new RegExp(`^${_URI_AUTHORITY_PATTERN}`, 'gi');
204
-        match = regex.exec(str);
205
-        if (match) {
206
-            let authority = match[1].substring(/* // */ 2);
207
-
208
-            str = str.substring(regex.lastIndex);
198
+        obj.host = authority;
209 199
 
210
-            // userinfo
211
-            const userinfoEndIndex = authority.indexOf('@');
200
+        // port
201
+        const portBeginIndex = authority.lastIndexOf(':');
212 202
 
213
-            if (userinfoEndIndex !== -1) {
214
-                authority = authority.substring(userinfoEndIndex + 1);
215
-            }
203
+        if (portBeginIndex !== -1) {
204
+            obj.port = authority.substring(portBeginIndex + 1);
205
+            authority = authority.substring(0, portBeginIndex);
206
+        }
216 207
 
217
-            obj.host = authority;
208
+        // hostname
209
+        obj.hostname = authority;
210
+    }
218 211
 
219
-            // port
220
-            const portBeginIndex = authority.lastIndexOf(':');
212
+    // pathname
213
+    regex = new RegExp(`^${_URI_PATH_PATTERN}`, 'gi');
214
+    match = regex.exec(str);
221 215
 
222
-            if (portBeginIndex !== -1) {
223
-                obj.port = authority.substring(portBeginIndex + 1);
224
-                authority = authority.substring(0, portBeginIndex);
225
-            }
216
+    let pathname;
226 217
 
227
-            obj.hostname = authority;
218
+    if (match) {
219
+        pathname = match[1];
220
+        str = str.substring(regex.lastIndex);
221
+    }
222
+    if (pathname) {
223
+        if (!pathname.startsWith('/')) {
224
+            pathname = `/${pathname}`;
228 225
         }
226
+    } else {
227
+        pathname = '/';
228
+    }
229
+    obj.pathname = pathname;
230
+
231
+    // query
232
+    if (str.startsWith('?')) {
233
+        let hashBeginIndex = str.indexOf('#', 1);
229 234
 
230
-        // pathname
231
-        regex = new RegExp(`^${_URI_PATH_PATTERN}`, 'gi');
232
-        match = regex.exec(str);
233
-        if (match) {
234
-            obj.pathname = match[1] || '/';
235
-            str = str.substring(regex.lastIndex);
235
+        if (hashBeginIndex === -1) {
236
+            hashBeginIndex = str.length;
236 237
         }
238
+        obj.search = str.substring(0, hashBeginIndex);
239
+        str = str.substring(hashBeginIndex);
240
+    } else {
241
+        obj.search = ''; // Google Chrome
242
+    }
243
+
244
+    // fragment
245
+    obj.hash = str.startsWith('#') ? str : '';
246
+
247
+    /* eslint-enable no-param-reassign */
248
+
249
+    return obj;
250
+}
251
+
252
+/**
253
+ * Parses a specific URI which (supposedly) references a Jitsi Meet resource
254
+ * (location).
255
+ *
256
+ * @param {(string|undefined)} uri - The URI to parse which (supposedly)
257
+ * references a Jitsi Meet resource (location).
258
+ * @returns {{
259
+ *     room: (string|undefined)
260
+ * }}
261
+ */
262
+export function _parseURIString(uri: ?string) {
263
+    if (typeof uri !== 'string') {
264
+        return undefined;
237 265
     }
238 266
 
239
-    return _getRoomAndDomainFromURLObject(obj);
267
+    const obj
268
+        = _parseStandardURIString(
269
+            _fixURIStringHierPart(_fixURIStringScheme(uri)));
270
+
271
+    // Add the properties that are specific to a Jitsi Meet resource (location)
272
+    // such as contextRoot, room:
273
+
274
+    // contextRoot
275
+    obj.contextRoot = getLocationContextRoot(obj);
276
+
277
+    // The room (name) is the last component of pathname.
278
+    const { pathname } = obj;
279
+
280
+    obj.room = pathname.substring(pathname.lastIndexOf('/') + 1) || undefined;
281
+
282
+    return obj;
240 283
 }

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

@@ -78,7 +78,7 @@ const _INTERCEPT_COMPONENT_RULES = [
78 78
     }
79 79
 ];
80 80
 
81
-export { _parseURIString } from './functions.native';
81
+export { getLocationContextRoot, _parseURIString } from './functions.native';
82 82
 
83 83
 /**
84 84
  * Determines which route is to be rendered in order to depict a specific Redux

+ 17
- 29
react/features/base/conference/actionTypes.js 查看文件

@@ -1,8 +1,7 @@
1 1
 import { Symbol } from '../react';
2 2
 
3 3
 /**
4
- * The type of the Redux action which signals that a specific conference has
5
- * failed.
4
+ * The type of (redux) action which signals that a specific conference failed.
6 5
  *
7 6
  * {
8 7
  *     type: CONFERENCE_FAILED,
@@ -13,8 +12,8 @@ import { Symbol } from '../react';
13 12
 export const CONFERENCE_FAILED = Symbol('CONFERENCE_FAILED');
14 13
 
15 14
 /**
16
- * The type of the Redux action which signals that a specific conference has
17
- * been joined.
15
+ * The type of (redux) action which signals that a specific conference was
16
+ * joined.
18 17
  *
19 18
  * {
20 19
  *     type: CONFERENCE_JOINED,
@@ -24,8 +23,7 @@ export const CONFERENCE_FAILED = Symbol('CONFERENCE_FAILED');
24 23
 export const CONFERENCE_JOINED = Symbol('CONFERENCE_JOINED');
25 24
 
26 25
 /**
27
- * The type of the Redux action which signals that a specific conference has
28
- * been left.
26
+ * The type of (redux) action which signals that a specific conference was left.
29 27
  *
30 28
  * {
31 29
  *     type: CONFERENCE_LEFT,
@@ -35,7 +33,7 @@ export const CONFERENCE_JOINED = Symbol('CONFERENCE_JOINED');
35 33
 export const CONFERENCE_LEFT = Symbol('CONFERENCE_LEFT');
36 34
 
37 35
 /**
38
- * The type of the Redux action which signals that a specific conference will be
36
+ * The type of (redux) action which signals that a specific conference will be
39 37
  * joined.
40 38
  *
41 39
  * {
@@ -46,7 +44,7 @@ export const CONFERENCE_LEFT = Symbol('CONFERENCE_LEFT');
46 44
 export const CONFERENCE_WILL_JOIN = Symbol('CONFERENCE_WILL_JOIN');
47 45
 
48 46
 /**
49
- * The type of the Redux action which signals that a specific conference will be
47
+ * The type of (redux) action which signals that a specific conference will be
50 48
  * left.
51 49
  *
52 50
  * {
@@ -57,8 +55,8 @@ export const CONFERENCE_WILL_JOIN = Symbol('CONFERENCE_WILL_JOIN');
57 55
 export const CONFERENCE_WILL_LEAVE = Symbol('CONFERENCE_WILL_LEAVE');
58 56
 
59 57
 /**
60
- * The type of the Redux action which signals that the lock state of a specific
61
- * <tt>JitsiConference</tt> changed.
58
+ * The type of (redux) action which signals that the lock state of a specific
59
+ * {@code JitsiConference} changed.
62 60
  *
63 61
  * {
64 62
  *     type: LOCK_STATE_CHANGED,
@@ -69,7 +67,7 @@ export const CONFERENCE_WILL_LEAVE = Symbol('CONFERENCE_WILL_LEAVE');
69 67
 export const LOCK_STATE_CHANGED = Symbol('LOCK_STATE_CHANGED');
70 68
 
71 69
 /**
72
- * The type of the Redux action which sets the audio-only flag for the current
70
+ * The type of (redux) action which sets the audio-only flag for the current
73 71
  * conference.
74 72
  *
75 73
  * {
@@ -80,8 +78,8 @@ export const LOCK_STATE_CHANGED = Symbol('LOCK_STATE_CHANGED');
80 78
 export const SET_AUDIO_ONLY = Symbol('SET_AUDIO_ONLY');
81 79
 
82 80
 /**
83
- * The type of redux action which signals that video will be muted because the
84
- * audio-only mode was enabled / disabled.
81
+ * The type of (redux) action which signals that video will be muted because the
82
+ * audio-only mode was enabled/disabled.
85 83
  *
86 84
  * {
87 85
  *     type: _SET_AUDIO_ONLY_VIDEO_MUTED,
@@ -105,7 +103,7 @@ export const _SET_AUDIO_ONLY_VIDEO_MUTED
105 103
 export const SET_LARGE_VIDEO_HD_STATUS = Symbol('SET_LARGE_VIDEO_HD_STATUS');
106 104
 
107 105
 /**
108
- * The type of redux action which sets the video channel's lastN (value).
106
+ * The type of (redux) action which sets the video channel's lastN (value).
109 107
  *
110 108
  * {
111 109
  *     type: SET_LASTN,
@@ -115,8 +113,8 @@ export const SET_LARGE_VIDEO_HD_STATUS = Symbol('SET_LARGE_VIDEO_HD_STATUS');
115 113
 export const SET_LASTN = Symbol('SET_LASTN');
116 114
 
117 115
 /**
118
- * The type of the Redux action which sets the password to join or lock a
119
- * specific JitsiConference.
116
+ * The type of (redux) action which sets the password to join or lock a specific
117
+ * {@code JitsiConference}.
120 118
  *
121 119
  * {
122 120
  *     type: SET_PASSWORD,
@@ -128,8 +126,8 @@ export const SET_LASTN = Symbol('SET_LASTN');
128 126
 export const SET_PASSWORD = Symbol('SET_PASSWORD');
129 127
 
130 128
 /**
131
- * The type of Redux action which signals that setting a password on a
132
- * JitsiConference failed (with an error).
129
+ * The type of (redux) action which signals that setting a password on a
130
+ * {@code JitsiConference} failed (with an error).
133 131
  *
134 132
  * {
135 133
  *     type: SET_PASSWORD_FAILED,
@@ -139,7 +137,7 @@ export const SET_PASSWORD = Symbol('SET_PASSWORD');
139 137
 export const SET_PASSWORD_FAILED = Symbol('SET_PASSWORD_FAILED');
140 138
 
141 139
 /**
142
- * The type of the Redux action which sets the name of the room of the
140
+ * The type of (redux) action which sets the name of the room of the
143 141
  * conference to be joined.
144 142
  *
145 143
  * {
@@ -148,13 +146,3 @@ export const SET_PASSWORD_FAILED = Symbol('SET_PASSWORD_FAILED');
148 146
  * }
149 147
  */
150 148
 export const SET_ROOM = Symbol('SET_ROOM');
151
-
152
-/**
153
- * The type of (Redux) action which sets the room URL.
154
- *
155
- * {
156
- *     type: SET_ROOM_URL,
157
- *     roomURL: URL
158
- * }
159
- */
160
-export const SET_ROOM_URL = Symbol('SET_ROOM_URL');

+ 1
- 18
react/features/base/conference/actions.js 查看文件

@@ -24,8 +24,7 @@ import {
24 24
     SET_LASTN,
25 25
     SET_PASSWORD,
26 26
     SET_PASSWORD_FAILED,
27
-    SET_ROOM,
28
-    SET_ROOM_URL
27
+    SET_ROOM
29 28
 } from './actionTypes';
30 29
 import {
31 30
     AVATAR_ID_COMMAND,
@@ -491,22 +490,6 @@ export function setRoom(room) {
491 490
     };
492 491
 }
493 492
 
494
-/**
495
- * Sets the room URL.
496
- *
497
- * @param {string} roomURL - Room url.
498
- * @returns {{
499
- *     type: SET_ROOM_URL,
500
- *     roomURL: URL
501
- * }}
502
- */
503
-export function setRoomURL(roomURL) {
504
-    return {
505
-        type: SET_ROOM_URL,
506
-        roomURL
507
-    };
508
-}
509
-
510 493
 /**
511 494
  * Toggles the audio-only flag for the current JitsiConference.
512 495
  *

+ 1
- 25
react/features/base/conference/reducer.js 查看文件

@@ -13,8 +13,7 @@ import {
13 13
     _SET_AUDIO_ONLY_VIDEO_MUTED,
14 14
     SET_LARGE_VIDEO_HD_STATUS,
15 15
     SET_PASSWORD,
16
-    SET_ROOM,
17
-    SET_ROOM_URL
16
+    SET_ROOM
18 17
 } from './actionTypes';
19 18
 import { isRoomValid } from './functions';
20 19
 
@@ -53,9 +52,6 @@ ReducerRegistry.register('features/base/conference', (state = {}, action) => {
53 52
 
54 53
     case SET_ROOM:
55 54
         return _setRoom(state, action);
56
-
57
-    case SET_ROOM_URL:
58
-        return _setRoomURL(state, action);
59 55
     }
60 56
 
61 57
     return state;
@@ -348,23 +344,3 @@ function _setRoom(state, action) {
348 344
      */
349 345
     return set(state, 'room', room);
350 346
 }
351
-
352
-/**
353
- * Reduces a specific Redux action SET_ROOM_URL of the feature base/conference.
354
- *
355
- * @param {Object} state - The Redux state of the feature base/conference.
356
- * @param {Action} action - The Redux action SET_ROOM_URL to reduce.
357
- * @private
358
- * @returns {Object} The new state of the feature base/conference after the
359
- * reduction of the specified action.
360
- */
361
-function _setRoomURL(state, action) {
362
-    const { roomURL } = action;
363
-
364
-    /**
365
-     * Room URL of the conference (to be) joined.
366
-     *
367
-     * @type {string}
368
-     */
369
-    return set(state, 'roomURL', roomURL);
370
-}

+ 27
- 7
react/features/base/connection/actionTypes.js 查看文件

@@ -1,26 +1,46 @@
1 1
 import { Symbol } from '../react';
2 2
 
3 3
 /**
4
- * Action type to signal that connection has disconnected.
4
+ * The type of (redux) action which signals that a connection disconnected.
5
+ *
6
+ * {
7
+ *     type: CONNECTION_DISCONNECTED,
8
+ *     connection: JitsiConnection,
9
+ *     message: string
10
+ * }
5 11
  */
6 12
 export const CONNECTION_DISCONNECTED = Symbol('CONNECTION_DISCONNECTED');
7 13
 
8 14
 /**
9
- * Action type to signal that have successfully established a connection.
15
+ * The type of (redux) action which signals that a connection was successfully
16
+ * established.
17
+ *
18
+ * {
19
+ *     type: CONNECTION_ESTABLISHED,
20
+ *     connection: JitsiConnection
21
+ * }
10 22
  */
11 23
 export const CONNECTION_ESTABLISHED = Symbol('CONNECTION_ESTABLISHED');
12 24
 
13 25
 /**
14
- * Action type to signal a connection failed.
26
+ * The type of (redux) action which signals that a connection failed.
27
+ *
28
+ * {
29
+ *     type: CONNECTION_FAILED,
30
+ *     connection: JitsiConnection,
31
+ *     error: string,
32
+ *     message: string
33
+ * }
15 34
  */
16 35
 export const CONNECTION_FAILED = Symbol('CONNECTION_FAILED');
17 36
 
18 37
 /**
19
- * Action to signal to change connection domain.
38
+ * The type of (redux) action which sets the location URL of the application,
39
+ * connection, conference, etc.
20 40
  *
21 41
  * {
22
- *     type: SET_DOMAIN,
23
- *     domain: string
42
+ *     type: SET_LOCATION_URL,
43
+ *     locationURL: ?URL
24 44
  * }
25 45
  */
26
-export const SET_DOMAIN = Symbol('SET_DOMAIN');
46
+export const SET_LOCATION_URL = Symbol('SET_LOCATION_URL');

+ 63
- 60
react/features/base/connection/actions.native.js 查看文件

@@ -9,7 +9,7 @@ import {
9 9
     CONNECTION_DISCONNECTED,
10 10
     CONNECTION_ESTABLISHED,
11 11
     CONNECTION_FAILED,
12
-    SET_DOMAIN
12
+    SET_LOCATION_URL
13 13
 } from './actionTypes';
14 14
 
15 15
 /**
@@ -88,7 +88,7 @@ export function connect() {
88 88
         function _onConnectionFailed(err) {
89 89
             unsubscribe();
90 90
             console.error('CONNECTION FAILED:', err);
91
-            dispatch(connectionFailed(connection, err, ''));
91
+            dispatch(connectionFailed(connection, err));
92 92
         }
93 93
 
94 94
         /**
@@ -108,57 +108,6 @@ export function connect() {
108 108
     };
109 109
 }
110 110
 
111
-/**
112
- * Closes connection.
113
- *
114
- * @returns {Function}
115
- */
116
-export function disconnect() {
117
-    return (dispatch: Dispatch<*>, getState: Function) => {
118
-        const state = getState();
119
-        const conference = state['features/base/conference'].conference;
120
-        const connection = state['features/base/connection'].connection;
121
-
122
-        let promise;
123
-
124
-        // Leave the conference.
125
-        if (conference) {
126
-            // In a fashion similar to JitsiConference's CONFERENCE_LEFT event
127
-            // (and the respective Redux action) which is fired after the
128
-            // conference has been left, notify the application about the
129
-            // intention to leave the conference.
130
-            dispatch(conferenceWillLeave(conference));
131
-
132
-            promise = conference.leave();
133
-        } else {
134
-            promise = Promise.resolve();
135
-        }
136
-
137
-        // Disconnect the connection.
138
-        if (connection) {
139
-            promise = promise.then(() => connection.disconnect());
140
-        }
141
-
142
-        return promise;
143
-    };
144
-}
145
-
146
-/**
147
- * Sets connection domain.
148
- *
149
- * @param {string} domain - Domain name.
150
- * @returns {{
151
- *      type: SET_DOMAIN,
152
- *      domain: string
153
- *  }}
154
- */
155
-export function setDomain(domain: string) {
156
-    return {
157
-        type: SET_DOMAIN,
158
-        domain
159
-    };
160
-}
161
-
162 111
 /**
163 112
  * Create an action for when the signaling connection has been lost.
164 113
  *
@@ -171,7 +120,7 @@ export function setDomain(domain: string) {
171 120
  *     message: string
172 121
  * }}
173 122
  */
174
-function _connectionDisconnected(connection, message: string) {
123
+function _connectionDisconnected(connection: Object, message: string) {
175 124
     return {
176 125
         type: CONNECTION_DISCONNECTED,
177 126
         connection,
@@ -184,11 +133,11 @@ function _connectionDisconnected(connection, message: string) {
184 133
  *
185 134
  * @param {JitsiConnection} connection - The JitsiConnection which was
186 135
  * established.
136
+ * @public
187 137
  * @returns {{
188 138
  *     type: CONNECTION_ESTABLISHED,
189 139
  *     connection: JitsiConnection
190 140
  * }}
191
- * @public
192 141
  */
193 142
 export function connectionEstablished(connection: Object) {
194 143
     return {
@@ -202,21 +151,75 @@ export function connectionEstablished(connection: Object) {
202 151
  *
203 152
  * @param {JitsiConnection} connection - The JitsiConnection which failed.
204 153
  * @param {string} error - Error.
205
- * @param {string} errorMessage - Error message.
154
+ * @param {string} message - Error message.
155
+ * @public
206 156
  * @returns {{
207 157
  *     type: CONNECTION_FAILED,
208 158
  *     connection: JitsiConnection,
209 159
  *     error: string,
210
- *     errorMessage: string
160
+ *     message: string
211 161
  * }}
212
- * @public
213 162
  */
214 163
 export function connectionFailed(
215
-    connection: Object, error: string, errorMessage: string) {
164
+        connection: Object,
165
+        error: string,
166
+        message: ?string) {
216 167
     return {
217 168
         type: CONNECTION_FAILED,
218 169
         connection,
219 170
         error,
220
-        errorMessage
171
+        message
172
+    };
173
+}
174
+
175
+/**
176
+ * Closes connection.
177
+ *
178
+ * @returns {Function}
179
+ */
180
+export function disconnect() {
181
+    return (dispatch: Dispatch<*>, getState: Function) => {
182
+        const state = getState();
183
+        const { conference } = state['features/base/conference'];
184
+        const { connection } = state['features/base/connection'];
185
+
186
+        let promise;
187
+
188
+        // Leave the conference.
189
+        if (conference) {
190
+            // In a fashion similar to JitsiConference's CONFERENCE_LEFT event
191
+            // (and the respective Redux action) which is fired after the
192
+            // conference has been left, notify the application about the
193
+            // intention to leave the conference.
194
+            dispatch(conferenceWillLeave(conference));
195
+
196
+            promise = conference.leave();
197
+        } else {
198
+            promise = Promise.resolve();
199
+        }
200
+
201
+        // Disconnect the connection.
202
+        if (connection) {
203
+            promise = promise.then(() => connection.disconnect());
204
+        }
205
+
206
+        return promise;
207
+    };
208
+}
209
+
210
+/**
211
+ * Sets the location URL of the application, connecton, conference, etc.
212
+ *
213
+ * @param {URL} [locationURL] - The location URL of the application,
214
+ * connection, conference, etc.
215
+ * @returns {{
216
+ *     type: SET_LOCATION_URL,
217
+ *     locationURL: URL
218
+ * }}
219
+ */
220
+export function setLocationURL(locationURL: ?URL) {
221
+    return {
222
+        type: SET_LOCATION_URL,
223
+        locationURL
221 224
     };
222 225
 }

+ 2
- 20
react/features/base/connection/actions.web.js 查看文件

@@ -8,11 +8,8 @@ import {
8 8
     WEBRTC_NOT_READY,
9 9
     WEBRTC_NOT_SUPPORTED
10 10
 } from '../lib-jitsi-meet';
11
-
12 11
 import UIEvents from '../../../../service/UI/UIEvents';
13 12
 
14
-import { SET_DOMAIN } from './actionTypes';
15
-
16 13
 declare var APP: Object;
17 14
 declare var config: Object;
18 15
 
@@ -20,7 +17,8 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
20 17
 
21 18
 export {
22 19
     connectionEstablished,
23
-    connectionFailed
20
+    connectionFailed,
21
+    setLocationURL
24 22
 } from './actions.native.js';
25 23
 
26 24
 /**
@@ -106,19 +104,3 @@ export function disconnect() {
106 104
     // app.
107 105
     return () => APP.conference.hangup();
108 106
 }
109
-
110
-/**
111
- * Sets connection domain.
112
- *
113
- * @param {string} domain - Domain name.
114
- * @returns {{
115
- *      type: SET_DOMAIN,
116
- *      domain: string
117
- *  }}
118
- */
119
-export function setDomain(domain: string) {
120
-    return {
121
-        type: SET_DOMAIN,
122
-        domain
123
-    };
124
-}

+ 0
- 28
react/features/base/connection/functions.js 查看文件

@@ -1,28 +0,0 @@
1
-/* @flow */
2
-
3
-/**
4
- * Returns current domain.
5
- *
6
- * @param {(Function|Object)} stateOrGetState - Redux getState() method or Redux
7
- * state.
8
- * @returns {(string|undefined)}
9
- */
10
-export function getDomain(stateOrGetState: Function | Object) {
11
-    const state
12
-        = typeof stateOrGetState === 'function'
13
-            ? stateOrGetState()
14
-            : stateOrGetState;
15
-    const { options } = state['features/base/connection'];
16
-    let domain;
17
-
18
-    try {
19
-        domain = options.hosts.domain;
20
-    } catch (e) {
21
-        // XXX The value of options or any of the properties descending from it
22
-        // may be undefined at some point in the execution (e.g. on start).
23
-        // Instead of multiple checks for the undefined value, we just wrap it
24
-        // in a try-catch block.
25
-    }
26
-
27
-    return domain;
28
-}

+ 0
- 1
react/features/base/connection/index.js 查看文件

@@ -1,5 +1,4 @@
1 1
 export * from './actions';
2 2
 export * from './actionTypes';
3
-export * from './functions';
4 3
 
5 4
 import './reducer';

+ 25
- 21
react/features/base/connection/reducer.js 查看文件

@@ -1,11 +1,11 @@
1 1
 /* @flow */
2 2
 
3
-import { ReducerRegistry, set } from '../redux';
3
+import { assign, ReducerRegistry, set } from '../redux';
4 4
 
5 5
 import {
6 6
     CONNECTION_DISCONNECTED,
7 7
     CONNECTION_ESTABLISHED,
8
-    SET_DOMAIN
8
+    SET_LOCATION_URL
9 9
 } from './actionTypes';
10 10
 
11 11
 /**
@@ -21,8 +21,8 @@ ReducerRegistry.register(
21 21
         case CONNECTION_ESTABLISHED:
22 22
             return _connectionEstablished(state, action);
23 23
 
24
-        case SET_DOMAIN:
25
-            return _setDomain(state, action);
24
+        case SET_LOCATION_URL:
25
+            return _setLocationURL(state, action);
26 26
         }
27 27
 
28 28
         return state;
@@ -38,8 +38,10 @@ ReducerRegistry.register(
38 38
  * @returns {Object} The new state of the feature base/connection after the
39 39
  * reduction of the specified action.
40 40
  */
41
-function _connectionDisconnected(state: Object, action: Object) {
42
-    if (state.connection === action.connection) {
41
+function _connectionDisconnected(
42
+        state: Object,
43
+        { connection }: { connection: Object }) {
44
+    if (state.connection === connection) {
43 45
         return set(state, 'connection', undefined);
44 46
     }
45 47
 
@@ -56,13 +58,15 @@ function _connectionDisconnected(state: Object, action: Object) {
56 58
  * @returns {Object} The new state of the feature base/connection after the
57 59
  * reduction of the specified action.
58 60
  */
59
-function _connectionEstablished(state: Object, action: Object) {
60
-    return set(state, 'connection', action.connection);
61
+function _connectionEstablished(
62
+        state: Object,
63
+        { connection }: { connection: Object }) {
64
+    return set(state, 'connection', connection);
61 65
 }
62 66
 
63 67
 /**
64
- * Constructs options to be passed to the constructor of JitsiConnection based
65
- * on a specific domain.
68
+ * Constructs options to be passed to the constructor of {@code JitsiConnection}
69
+ * based on a specific domain.
66 70
  *
67 71
  * @param {string} domain - The domain with which the returned options are to be
68 72
  * populated.
@@ -105,20 +109,20 @@ function _constructOptions(domain: string) {
105 109
 }
106 110
 
107 111
 /**
108
- * Reduces a specific Redux action SET_DOMAIN of the feature base/connection.
112
+ * Reduces a specific redux action {@link SET_LOCATION_URL} of the feature
113
+ * base/connection.
109 114
  *
110
- * @param {Object} state - The Redux state of the feature base/connection.
111
- * @param {Action} action - The Redux action SET_DOMAIN to reduce.
115
+ * @param {Object} state - The redux state of the feature base/connection.
116
+ * @param {Action} action - The redux action {@code SET_LOCATION_URL} to reduce.
112 117
  * @private
113 118
  * @returns {Object} The new state of the feature base/connection after the
114 119
  * reduction of the specified action.
115 120
  */
116
-function _setDomain(state: Object, action: Object) {
117
-    return {
118
-        ...state,
119
-        options: {
120
-            ...state.options,
121
-            ..._constructOptions(action.domain)
122
-        }
123
-    };
121
+function _setLocationURL(
122
+        state: Object,
123
+        { locationURL }: { locationURL: ?URL }) {
124
+    return assign(state, {
125
+        locationURL,
126
+        options: locationURL ? _constructOptions(locationURL.host) : undefined
127
+    });
124 128
 }

+ 3
- 3
react/features/base/lib-jitsi-meet/functions.js 查看文件

@@ -52,13 +52,13 @@ export function isFatalJitsiConnectionError(error: string) {
52 52
 }
53 53
 
54 54
 /**
55
- * Loads config.js file from remote server.
55
+ * Loads config.js from a specific remote server.
56 56
  *
57 57
  * @param {string} host - Host where config.js is hosted.
58
- * @param {string} path='/config.js' - Relative pah to config.js file.
58
+ * @param {string} path='config.js' - Relative pah to config.js file.
59 59
  * @returns {Promise<Object>}
60 60
  */
61
-export function loadConfig(host: string, path: string = '/config.js') {
61
+export function loadConfig(host: string, path: string = 'config.js') {
62 62
     let promise;
63 63
 
64 64
     if (typeof APP === 'undefined') {

+ 11
- 11
react/features/jwt/middleware.js 查看文件

@@ -1,7 +1,7 @@
1 1
 import jwtDecode from 'jwt-decode';
2 2
 
3
-import { SET_ROOM_URL } from '../base/conference';
4 3
 import { parseURLParams, SET_CONFIG } from '../base/config';
4
+import { SET_LOCATION_URL } from '../base/connection';
5 5
 import { MiddlewareRegistry } from '../base/redux';
6 6
 
7 7
 import { setJWT } from './actions';
@@ -17,13 +17,13 @@ import { SET_JWT } from './actionTypes';
17 17
 MiddlewareRegistry.register(store => next => action => {
18 18
     switch (action.type) {
19 19
     case SET_CONFIG:
20
-    case SET_ROOM_URL:
20
+    case SET_LOCATION_URL:
21 21
         // XXX The JSON Web Token (JWT) is not the only piece of state that we
22 22
         // have decided to store in the feature jwt, there is isGuest as well
23 23
         // which depends on the states of the features base/config and jwt. So
24
-        // the JSON Web Token comes from the room's URL and isGuest needs a
25
-        // recalculation upon SET_CONFIG as well.
26
-        return _setConfigOrRoomURL(store, next, action);
24
+        // the JSON Web Token comes from the conference/room's URL and isGuest
25
+        // needs a recalculation upon SET_CONFIG as well.
26
+        return _setConfigOrLocationURL(store, next, action);
27 27
 
28 28
     case SET_JWT:
29 29
         return _setJWT(store, next, action);
@@ -34,7 +34,7 @@ MiddlewareRegistry.register(store => next => action => {
34 34
 
35 35
 /**
36 36
  * Notifies the feature jwt that the action {@link SET_CONFIG} or
37
- * {@link SET_ROOM_URL} is being dispatched within a specific Redux
37
+ * {@link SET_LOCATION_URL} is being dispatched within a specific Redux
38 38
  * {@code store}.
39 39
  *
40 40
  * @param {Store} store - The Redux store in which the specified {@code action}
@@ -42,20 +42,20 @@ MiddlewareRegistry.register(store => next => action => {
42 42
  * @param {Dispatch} next - The Redux dispatch function to dispatch the
43 43
  * specified {@code action} to the specified {@code store}.
44 44
  * @param {Action} action - The Redux action {@code SET_CONFIG} or
45
- * {@code SET_ROOM_NAME} which is being dispatched in the specified
45
+ * {@code SET_LOCATION_URL} which is being dispatched in the specified
46 46
  * {@code store}.
47 47
  * @private
48 48
  * @returns {Object} The new state that is the result of the reduction of the
49 49
  * specified {@code action}.
50 50
  */
51
-function _setConfigOrRoomURL({ dispatch, getState }, next, action) {
51
+function _setConfigOrLocationURL({ dispatch, getState }, next, action) {
52 52
     const result = next(action);
53 53
 
54
-    const { roomURL } = getState()['features/base/conference'];
54
+    const { locationURL } = getState()['features/base/connection'];
55 55
     let jwt;
56 56
 
57
-    if (roomURL) {
58
-        jwt = parseURLParams(roomURL, true, 'search').jwt;
57
+    if (locationURL) {
58
+        jwt = parseURLParams(locationURL, true, 'search').jwt;
59 59
     }
60 60
     dispatch(setJWT(jwt));
61 61
 

+ 5
- 11
react/features/overlay/reducer.js 查看文件

@@ -47,15 +47,13 @@ ReducerRegistry.register('features/overlay', (state = {}, action) => {
47 47
  * the specified action.
48 48
  * @private
49 49
  */
50
-function _conferenceFailed(state, action) {
51
-    const error = action.error;
52
-
50
+function _conferenceFailed(state, { error, message }) {
53 51
     if (error === JitsiConferenceErrors.FOCUS_LEFT
54 52
             || error === JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE) {
55 53
         return assign(state, {
56 54
             haveToReload: true,
57 55
             isNetworkFailure: false,
58
-            reason: action.errorMessage
56
+            reason: message
59 57
         });
60 58
     }
61 59
 
@@ -84,13 +82,9 @@ function _connectionEstablished(state) {
84 82
  * the specified action.
85 83
  * @private
86 84
  */
87
-function _connectionFailed(state, action) {
88
-    const error = action.error;
89
-
85
+function _connectionFailed(state, { error, message }) {
90 86
     if (isFatalJitsiConnectionError(error)) {
91
-        const errorMessage = action.errorMessage;
92
-
93
-        logger.error(`XMPP connection error: ${errorMessage}`);
87
+        logger.error(`XMPP connection error: ${message}`);
94 88
 
95 89
         return assign(state, {
96 90
             haveToReload: true,
@@ -99,7 +93,7 @@ function _connectionFailed(state, action) {
99 93
             // considered a network type of failure.
100 94
             isNetworkFailure:
101 95
                 error === JitsiConnectionErrors.CONNECTION_DROPPED_ERROR,
102
-            reason: `xmpp-conn-dropped: ${errorMessage}`
96
+            reason: `xmpp-conn-dropped: ${message}`
103 97
         });
104 98
     }
105 99
 

+ 9
- 26
react/features/share-room/actions.js 查看文件

@@ -12,18 +12,17 @@ import { BEGIN_SHARE_ROOM, END_SHARE_ROOM } from './actionTypes';
12 12
 export function beginShareRoom(roomURL: ?string): Function {
13 13
     return (dispatch, getState) => {
14 14
         if (!roomURL) {
15
-            const { conference, room } = getState()['features/base/conference'];
15
+            const { locationURL } = getState()['features/base/connection'];
16 16
 
17
-            // eslint-disable-next-line no-param-reassign
18
-            roomURL = _getRoomURL(conference, room);
19
-        }
20
-
21
-        if (roomURL) {
22
-            dispatch({
23
-                type: BEGIN_SHARE_ROOM,
24
-                roomURL
25
-            });
17
+            if (locationURL) {
18
+                // eslint-disable-next-line no-param-reassign
19
+                roomURL = locationURL.toString();
20
+            }
26 21
         }
22
+        roomURL && dispatch({
23
+            type: BEGIN_SHARE_ROOM,
24
+            roomURL
25
+        });
27 26
     };
28 27
 }
29 28
 
@@ -47,19 +46,3 @@ export function endShareRoom(roomURL: string, shared: boolean): Object {
47 46
         shared
48 47
     };
49 48
 }
50
-
51
-/**
52
- * Gets the public URL of a conference/room.
53
- *
54
- * @param {JitsiConference} conference - The JitsiConference to share the URL
55
- * of.
56
- * @param {string} room - The name of the room to share the URL of.
57
- * @private
58
- * @returns {string|null}
59
- */
60
-function _getRoomURL(conference, room) {
61
-    return (
62
-        conference
63
-            && room
64
-            && `https://${conference.connection.options.hosts.domain}/${room}`);
65
-}

Loading…
取消
儲存