Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

getRouteToRender.web.js 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { generateRoomWithoutSeparator } from '@jitsi/js-utils/random';
  2. import { isRoomValid } from '../base/conference';
  3. import { isSupportedBrowser } from '../base/environment';
  4. import { toState } from '../base/redux';
  5. import { Conference } from '../conference';
  6. import { getDeepLinkingPage } from '../deep-linking';
  7. import { UnsupportedDesktopBrowser } from '../unsupported-browser';
  8. import { BlankPage, WelcomePage } from '../welcome';
  9. import { getCustomLandingPageURL, isWelcomePageEnabled } from '../welcome/functions';
  10. /**
  11. * Determines which route is to be rendered in order to depict a specific Redux
  12. * store.
  13. *
  14. * @param {(Function|Object)} stateful - THe redux store, state, or
  15. * {@code getState} function.
  16. * @returns {Promise<Object>}
  17. */
  18. export function _getRouteToRender(stateful) {
  19. const state = toState(stateful);
  20. return _getWebConferenceRoute(state) || _getWebWelcomePageRoute(state);
  21. }
  22. /**
  23. * Returns the {@code Route} to display when trying to access a conference if
  24. * a valid conference is being joined.
  25. *
  26. * @param {Object} state - The redux state.
  27. * @returns {Promise|undefined}
  28. */
  29. function _getWebConferenceRoute(state) {
  30. if (!isRoomValid(state['features/base/conference'].room)) {
  31. return;
  32. }
  33. const route = _getEmptyRoute();
  34. // Update the location if it doesn't match. This happens when a room is
  35. // joined from the welcome page. The reason for doing this instead of using
  36. // the history API is that we want to load the config.js which takes the
  37. // room into account.
  38. const { locationURL } = state['features/base/connection'];
  39. if (window.location.href !== locationURL.href) {
  40. route.href = locationURL.href;
  41. return Promise.resolve(route);
  42. }
  43. return getDeepLinkingPage(state)
  44. .then(deepLinkComponent => {
  45. if (deepLinkComponent) {
  46. route.component = deepLinkComponent;
  47. } else if (isSupportedBrowser()) {
  48. route.component = Conference;
  49. } else {
  50. route.component = UnsupportedDesktopBrowser;
  51. }
  52. return route;
  53. });
  54. }
  55. /**
  56. * Returns the {@code Route} to display when trying to access the welcome page.
  57. *
  58. * @param {Object} state - The redux state.
  59. * @returns {Promise<Object>}
  60. */
  61. function _getWebWelcomePageRoute(state) {
  62. const route = _getEmptyRoute();
  63. if (isWelcomePageEnabled(state)) {
  64. if (isSupportedBrowser()) {
  65. const customLandingPage = getCustomLandingPageURL(state);
  66. if (customLandingPage) {
  67. route.href = customLandingPage;
  68. } else {
  69. route.component = WelcomePage;
  70. }
  71. } else {
  72. route.component = UnsupportedDesktopBrowser;
  73. }
  74. } else {
  75. // Web: if the welcome page is disabled, go directly to a random room.
  76. const url = new URL(window.location.href);
  77. url.pathname += generateRoomWithoutSeparator();
  78. route.href = url.href;
  79. }
  80. return Promise.resolve(route);
  81. }
  82. /**
  83. * Returns the default {@code Route}.
  84. *
  85. * @returns {Object}
  86. */
  87. function _getEmptyRoute() {
  88. return {
  89. component: BlankPage,
  90. href: undefined
  91. };
  92. }