2017-05-26 17:15:40 -05:00
|
|
|
/* @flow */
|
2017-01-10 15:55:31 -06:00
|
|
|
|
2017-01-28 19:56:35 -06:00
|
|
|
import { RouteRegistry } from '../base/react';
|
2017-01-10 15:55:31 -06:00
|
|
|
|
2017-08-31 23:13:59 -05:00
|
|
|
import { WelcomePage } from './components';
|
|
|
|
|
import {
|
|
|
|
|
generateRoomWithoutSeparator,
|
|
|
|
|
isWelcomePageAppEnabled,
|
|
|
|
|
isWelcomePageUserEnabled
|
|
|
|
|
} from './functions';
|
2017-05-26 17:15:40 -05:00
|
|
|
|
2017-08-17 15:50:49 +02:00
|
|
|
/**
|
2017-10-01 01:35:19 -05:00
|
|
|
* Register route for {@code WelcomePage}.
|
2017-08-17 15:50:49 +02:00
|
|
|
*/
|
|
|
|
|
RouteRegistry.register({
|
2017-08-31 23:13:59 -05:00
|
|
|
component: WelcomePage,
|
2017-01-10 15:55:31 -06:00
|
|
|
onEnter,
|
|
|
|
|
path: '/'
|
|
|
|
|
});
|
2016-12-12 23:13:17 +02:00
|
|
|
|
|
|
|
|
/**
|
2017-10-01 01:35:19 -05:00
|
|
|
* Skips the {@code WelcomePage} if it is disabled (by the app or the user).
|
2016-12-12 23:13:17 +02:00
|
|
|
*
|
2017-08-31 23:13:59 -05:00
|
|
|
* @param {Object} store - The redux store.
|
2017-01-10 15:55:31 -06:00
|
|
|
* @param {Function} replace - The function to redirect to another path.
|
2016-12-12 23:13:17 +02:00
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
2017-08-31 23:13:59 -05:00
|
|
|
function onEnter({ getState }, replace) {
|
|
|
|
|
if (isWelcomePageAppEnabled(getState)) {
|
|
|
|
|
isWelcomePageUserEnabled(getState)
|
|
|
|
|
|| replace(`/${generateRoomWithoutSeparator()}`);
|
|
|
|
|
} else {
|
|
|
|
|
replace(undefined);
|
2016-12-12 23:13:17 +02:00
|
|
|
}
|
|
|
|
|
}
|