[RN] Simplify the source code

This commit is contained in:
Lyubo Marinov 2017-02-23 17:12:50 -06:00
parent b226c3aca3
commit f50a31b4e8
3 changed files with 19 additions and 18 deletions

View File

@ -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

View File

@ -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;

View File

@ -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)
}
};
}