jiti-meet/react/features/conference/route.js

106 lines
2.8 KiB
JavaScript
Raw Normal View History

2017-10-13 19:31:05 +00:00
// @flow
import ConferenceUrl from '../../../modules/URL/ConferenceUrl';
import { obtainConfig } from '../base/config';
import { RouteRegistry } from '../base/react';
2017-01-13 22:37:53 +00:00
import { Conference } from './components';
2017-10-13 19:31:05 +00:00
declare var APP: Object;
declare var config: Object;
const logger = require('jitsi-meet-logger').getLogger(__filename);
/**
* Register route for Conference (page).
*/
RouteRegistry.register({
component: Conference,
2017-01-04 17:01:25 +00:00
onEnter: () => {
// XXX If config or jwt are set by hash or query parameters
2017-01-04 17:01:25 +00:00
// Getting raw URL before stripping it.
_obtainConfigAndInit();
},
path: '/:room'
});
/**
2017-05-31 05:24:34 +00:00
* Initialization of the app.
*
2017-05-31 05:24:34 +00:00
* @private
* @returns {void}
*/
function _initConference() {
APP.ConferenceUrl = new ConferenceUrl(window.location);
}
/**
* Promise wrapper on obtain config method. When HttpConfigFetch will be moved
* to React app it's better to use load config instead.
*
2017-02-01 04:25:09 +00:00
* @param {string} location - URL of the domain from which the config is to be
* obtained.
* @param {string} room - Room name.
* @private
* @returns {Promise}
*/
2017-10-13 19:31:05 +00:00
function _obtainConfig(location: string, room: string) {
return new Promise((resolve, reject) =>
obtainConfig(location, room, (success, error) => {
success ? resolve() : reject(error);
})
);
}
/**
* 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.
*
* @private
* @returns {void}
*/
function _obtainConfigAndInit() {
// Skip initialization if conference is initialized already.
if (typeof APP !== 'undefined' && !APP.ConferenceUrl) {
const location = config.configLocation;
const room = APP.conference.roomName;
if (location) {
_obtainConfig(location, room)
.then(() => {
_obtainConfigHandler();
_initConference();
})
.catch(err => {
ref(notifications): convert some dialogs to error or warning notifica… (#1991) * ref(notifications): convert some dialogs to error or warning notifications - Expand the configurability of the Notification component so warnings and errors can be displayed. - Allow Notification to take in arbitrary text for the body. - Rename defaultTitleKey to titleKey for consistency with descriptionKey. * ref(notifications): remove openReportDialog method openReportDialog is a wrapper around showError that adds a logger statement. It is being called in one place only so remove the method and have that one place call logger. * ref(notifications): UI.showTrackNotWorkingDialog takes a boolean Change UI.showTrackNotWorkingDialog so it takes a boolean arguments instead of the entire track. A small refactor so the method needs to know less. * [squash] Fixes eslint errors * WiP: Fixes desktop sharing error strings and adds support button * [squash] Fix icons appearances * [squash] Fix translate titles and messages * [squash] fix(translation): Fixes incorrect password string * [squash] fix(recording): Fixes recording message * [squash] fix(warning): Turns some warnings to errors and makes support link optional. * [squash] fix(translation): Addressing language comments * [squash] Fixes jsdoc and formatting * [squash] fix(noopener): Fixes window.open noopener * [squash] fix(constants): Extract constants and refactor NotificationWithToggle * [squash] fix(lang): Fixes camera and mic error titles * [squash] fix(supportLink): Renames addSupportLink to hideErrorSupportLink
2017-11-03 19:05:03 +00:00
logger.log(err);
// Show obtain config error.
ref(notifications): convert some dialogs to error or warning notifica… (#1991) * ref(notifications): convert some dialogs to error or warning notifications - Expand the configurability of the Notification component so warnings and errors can be displayed. - Allow Notification to take in arbitrary text for the body. - Rename defaultTitleKey to titleKey for consistency with descriptionKey. * ref(notifications): remove openReportDialog method openReportDialog is a wrapper around showError that adds a logger statement. It is being called in one place only so remove the method and have that one place call logger. * ref(notifications): UI.showTrackNotWorkingDialog takes a boolean Change UI.showTrackNotWorkingDialog so it takes a boolean arguments instead of the entire track. A small refactor so the method needs to know less. * [squash] Fixes eslint errors * WiP: Fixes desktop sharing error strings and adds support button * [squash] Fix icons appearances * [squash] Fix translate titles and messages * [squash] fix(translation): Fixes incorrect password string * [squash] fix(recording): Fixes recording message * [squash] fix(warning): Turns some warnings to errors and makes support link optional. * [squash] fix(translation): Addressing language comments * [squash] Fixes jsdoc and formatting * [squash] fix(noopener): Fixes window.open noopener * [squash] fix(constants): Extract constants and refactor NotificationWithToggle * [squash] fix(lang): Fixes camera and mic error titles * [squash] fix(supportLink): Renames addSupportLink to hideErrorSupportLink
2017-11-03 19:05:03 +00:00
APP.UI.messageHandler.showError({
titleKey: 'connection.CONNFAIL',
descriptionKey: 'dialog.connectError'
});
});
} else {
_initConference();
}
}
}
/**
* Obtain config handler.
*
* @private
* @returns {Promise}
*/
function _obtainConfigHandler() {
const now = window.performance.now();
APP.connectionTimes['configuration.fetched'] = now;
logger.log('(TIME) configuration fetched:\t', now);
}