diff --git a/react/features/conference/components/Conference.web.js b/react/features/conference/components/Conference.web.js index c2470999f..ab8b5a9fe 100644 --- a/react/features/conference/components/Conference.web.js +++ b/react/features/conference/components/Conference.web.js @@ -6,7 +6,6 @@ import { connect, disconnect } from '../../base/connection'; -import { obtainConfigAndInit } from '../actions'; /** * For legacy reasons, inline style for display none. @@ -28,7 +27,6 @@ class Conference extends Component { * @inheritdoc */ componentDidMount() { - this.props.dispatch(obtainConfigAndInit()); APP.UI.start(); // XXX Temporary solution until we add React translation. diff --git a/react/features/conference/functions.js b/react/features/conference/functions.js index 6018773d9..97e5f010c 100644 --- a/react/features/conference/functions.js +++ b/react/features/conference/functions.js @@ -1,5 +1,71 @@ -/* global APP */ +/* global APP, config */ import HttpConfigFetch from '../../../modules/config/HttpConfigFetch'; +import ConferenceUrl from '../../../modules/URL/ConferenceUrl'; +import BoshAddressChoice from '../../../modules/config/BoshAddressChoice'; +const logger = require('jitsi-meet-logger').getLogger(__filename); + +/** + * If we have an HTTP endpoint for getting config.json configured + * we're going to read it and override properties from config.js and + * interfaceConfig.js. If there is no endpoint we'll just + * continue with initialization. + * Keep in mind that if the endpoint has been configured and we fail + * to obtain the config for any reason then the conference won't + * start and error message will be displayed to the user. + * + * @returns {Function} + */ +export function obtainConfigAndInit() { + // Skip initialization if conference is already initialized + if (!APP.ConferenceUrl) { + const room = APP.conference.roomName; + + if (config.configLocation) { + const location = config.configLocation; + + obtainConfig(location, room) + .then(_obtainConfigHandler) + .then(_initConference) + .catch(err => { + // Show obtain config error, + // pass the error object for report + APP.UI.messageHandler.openReportDialog( + null, 'dialog.connectError', err); + }); + } else { + BoshAddressChoice.chooseAddress(config, room); + _initConference(); + } + } +} + +/** + * Obtain config handler. + * + * @returns {Promise} + * @private + */ +function _obtainConfigHandler() { + const now = window.performance.now(); + + APP.connectionTimes['configuration.fetched'] = now; + logger.log('(TIME) configuration fetched:\t', now); + + return Promise.resolve(); +} + +/** + * Initialization of the app. + * + * @returns {void} + * @private + */ +function _initConference() { + setTokenData(); + + // Initialize the conference URL handler + APP.ConferenceUrl = new ConferenceUrl(window.location); +} /** * Promise wrapper on obtain config method. diff --git a/react/features/conference/route.js b/react/features/conference/route.js index 9efac31b9..35250efa6 100644 --- a/react/features/conference/route.js +++ b/react/features/conference/route.js @@ -1,11 +1,17 @@ import { RouteRegistry } from '../base/navigator'; import { Conference } from './components'; +import { obtainConfigAndInit } from './functions'; /** * Register route for Conference (page). */ RouteRegistry.register({ component: Conference, - path: '/:room' + path: '/:room', + onEnter: () => { + // XXX: If config or jwt are set by hash or query parameters + // Getting raw URL before stripping it. + obtainConfigAndInit(); + } });