From f50a31b4e851dad48a652a13ff683e33c797f22b Mon Sep 17 00:00:00 2001 From: Lyubo Marinov Date: Thu, 23 Feb 2017 17:12:50 -0600 Subject: [PATCH] [RN] Simplify the source code --- react/features/base/connection/actions.native.js | 13 ++++++------- react/features/base/connection/functions.js | 12 ++++++------ react/features/base/connection/reducer.js | 12 +++++++----- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/react/features/base/connection/actions.native.js b/react/features/base/connection/actions.native.js index 016fce7ac..d562ab20a 100644 --- a/react/features/base/connection/actions.native.js +++ b/react/features/base/connection/actions.native.js @@ -22,17 +22,16 @@ const JitsiConnectionEvents = JitsiMeetJS.events.connection; export function connect() { return (dispatch: Dispatch<*>, getState: Function) => { const state = getState(); - const connectionOptions - = state['features/base/connection'].connectionOptions; - const room = state['features/base/conference'].room; + const { options } = state['features/base/connection']; + const { room } = state['features/base/conference']; const connection = new JitsiMeetJS.JitsiConnection( - connectionOptions.appId, - connectionOptions.token, + options.appId, + options.token, { - ...connectionOptions, + ...options, bosh: - connectionOptions.bosh + options.bosh // XXX The Jitsi Meet deployments require the room // argument to be in lower case at the time of this diff --git a/react/features/base/connection/functions.js b/react/features/base/connection/functions.js index b69daa7dc..230df3049 100644 --- a/react/features/base/connection/functions.js +++ b/react/features/base/connection/functions.js @@ -12,16 +12,16 @@ export function getDomain(stateOrGetState: Function | Object) { = typeof stateOrGetState === 'function' ? stateOrGetState() : stateOrGetState; - const connection = state['features/base/connection']; + const { options } = state['features/base/connection']; let domain; try { - domain = connection.connectionOptions.hosts.domain; + domain = options.hosts.domain; } catch (e) { - // XXX The value of connectionOptions or any of the properties - // descending from it may be undefined at some point in the execution - // (e.g. on start). Instead of multiple checks for the undefined value, - // we just wrap it in a try-catch block. + // XXX The value of options or any of the properties descending from it + // may be undefined at some point in the execution (e.g. on start). + // Instead of multiple checks for the undefined value, we just wrap it + // in a try-catch block. } return domain; diff --git a/react/features/base/connection/reducer.js b/react/features/base/connection/reducer.js index 739587dc7..49bb5925c 100644 --- a/react/features/base/connection/reducer.js +++ b/react/features/base/connection/reducer.js @@ -69,7 +69,7 @@ function _connectionEstablished(state: Object, action: Object) { * @private * @returns {Object} */ -function _constructConnectionOptions(domain: string) { +function _constructOptions(domain: string) { // FIXME The HTTPS scheme for the BOSH URL works with meet.jit.si on both // mobile & Web. It also works with beta.meet.jit.si on Web. Unfortunately, // it doesn't work with beta.meet.jit.si on mobile. Temporarily, use the @@ -96,7 +96,9 @@ function _constructConnectionOptions(domain: string) { bosh: `${String(boshProtocol)}//${domain}/http-bind`, hosts: { domain, - focus: `focus.${domain}`, + + // Required by: + // - lib-jitsi-meet/modules/xmpp/xmpp.js muc: `conference.${domain}` } }; @@ -114,9 +116,9 @@ function _constructConnectionOptions(domain: string) { function _setDomain(state: Object, action: Object) { return { ...state, - connectionOptions: { - ...state.connectionOptions, - ..._constructConnectionOptions(action.domain) + options: { + ...state.options, + ..._constructOptions(action.domain) } }; }