You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

route.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* @flow */
  2. import { RouteRegistry } from '../base/react';
  3. import { WelcomePage } from './components';
  4. import { generateRoomWithoutSeparator } from './roomnameGenerator';
  5. declare var APP: Object;
  6. declare var config: Object;
  7. /**
  8. * Register route for WelcomePage.
  9. */
  10. RouteRegistry.register({
  11. component: WelcomePage,
  12. onEnter,
  13. path: '/'
  14. });
  15. /**
  16. * If the Welcome page/screen is disabled, generates a (random) room (name) so
  17. * that the Welcome page/screen is skipped and the Conference page/screen is
  18. * presented instead.
  19. *
  20. * @param {Object} nextState - The next Router state.
  21. * @param {Function} replace - The function to redirect to another path.
  22. * @returns {void}
  23. */
  24. function onEnter(nextState, replace) {
  25. // The disabling of the Welcome page by redirecting to a random room name is
  26. // a feature (1) we have on Web/React and (2) we do not want on mobile/React
  27. // Native (at the time of this writing).
  28. if (typeof APP === 'object'
  29. // TODO Technically, there is features/base/config now so it is
  30. // preferable to read config(uration) values from there and not rely
  31. // on a global variable. However, the redux store is not available
  32. // here at the time of this writing. Given the current (1) Web
  33. // exclusivity of the feature and (2) the reliance on other global
  34. // variables (e.g. APP), go with the global variable for now in
  35. // order to minimize the effort involved.
  36. && !(config.enableWelcomePage
  37. && APP.settings.isWelcomePageEnabled())) {
  38. const room = generateRoomWithoutSeparator();
  39. replace(`/${room}`);
  40. }
  41. }