2017-05-26 22:15:40 +00:00
|
|
|
/* @flow */
|
2017-01-10 21:55:31 +00:00
|
|
|
|
2017-01-29 01:56:35 +00:00
|
|
|
import { RouteRegistry } from '../base/react';
|
2017-01-10 21:55:31 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
import { WelcomePage } from './components';
|
2017-04-14 18:08:54 +00:00
|
|
|
import { generateRoomWithoutSeparator } from './roomnameGenerator';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2017-05-26 22:15:40 +00:00
|
|
|
declare var APP: Object;
|
|
|
|
declare var config: Object;
|
|
|
|
|
2017-01-10 21:55:31 +00:00
|
|
|
/**
|
|
|
|
* Register route for WelcomePage.
|
|
|
|
*/
|
|
|
|
RouteRegistry.register({
|
|
|
|
component: WelcomePage,
|
|
|
|
onEnter,
|
|
|
|
path: '/'
|
|
|
|
});
|
2016-12-12 21:13:17 +00:00
|
|
|
|
|
|
|
/**
|
2017-01-10 21:55:31 +00:00
|
|
|
* If the Welcome page/screen is disabled, generates a (random) room (name) so
|
|
|
|
* that the Welcome page/screen is skipped and the Conference page/screen is
|
|
|
|
* presented instead.
|
2016-12-12 21:13:17 +00:00
|
|
|
*
|
2017-01-10 21:55:31 +00:00
|
|
|
* @param {Object} nextState - The next Router state.
|
|
|
|
* @param {Function} replace - The function to redirect to another path.
|
2016-12-12 21:13:17 +00:00
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
function onEnter(nextState, replace) {
|
2017-05-26 22:15:40 +00:00
|
|
|
// The disabling of the Welcome page by redirecting to a random room name is
|
|
|
|
// a feature (1) we have on Web/React and (2) we do not want on mobile/React
|
|
|
|
// Native (at the time of this writing).
|
|
|
|
if (typeof APP === 'object'
|
|
|
|
|
|
|
|
// TODO Technically, there is features/base/config now so it is
|
|
|
|
// preferable to read config(uration) values from there and not rely
|
|
|
|
// on a global variable. However, the redux store is not available
|
|
|
|
// here at the time of this writing. Given the current (1) Web
|
|
|
|
// exclusivity of the feature and (2) the reliance on other global
|
|
|
|
// variables (e.g. APP), go with the global variable for now in
|
|
|
|
// order to minimize the effort involved.
|
|
|
|
&& !(config.enableWelcomePage
|
|
|
|
&& APP.settings.isWelcomePageEnabled())) {
|
2017-01-10 21:55:31 +00:00
|
|
|
const room = generateRoomWithoutSeparator();
|
2016-12-12 21:13:17 +00:00
|
|
|
|
2017-01-10 21:55:31 +00:00
|
|
|
replace(`/${room}`);
|
2016-12-12 21:13:17 +00:00
|
|
|
}
|
|
|
|
}
|