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