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.

App.web.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { appInit, detectPlatform } from '../actions';
  2. import { AbstractApp } from './AbstractApp';
  3. /**
  4. * Root application component.
  5. *
  6. * @extends AbstractApp
  7. */
  8. export class App extends AbstractApp {
  9. /**
  10. * App component's property types.
  11. *
  12. * @static
  13. */
  14. static propTypes = AbstractApp.propTypes
  15. /**
  16. * Inits the app before component will mount.
  17. *
  18. * @inheritdoc
  19. */
  20. componentWillMount(...args) {
  21. super.componentWillMount(...args);
  22. this.props.store.dispatch(detectPlatform());
  23. this.props.store.dispatch(appInit());
  24. }
  25. /**
  26. * Gets a Location object from the window with information about the current
  27. * location of the document.
  28. *
  29. * @inheritdoc
  30. */
  31. _getWindowLocation() {
  32. return window.location;
  33. }
  34. /**
  35. * Navigates to a specific Route (via platform-specific means).
  36. *
  37. * @param {Route} route - The Route to which to navigate.
  38. * @protected
  39. * @returns {void}
  40. */
  41. _navigate(route) {
  42. let path = route.path;
  43. const store = this.props.store;
  44. // The syntax :room bellow is defined by react-router. It "matches a URL
  45. // segment up to the next /, ?, or #. The matched string is called a
  46. // param."
  47. path
  48. = path.replace(
  49. /:room/g,
  50. store.getState()['features/base/conference'].room);
  51. // Navigate to the specified Route.
  52. const windowLocation = this._getWindowLocation();
  53. if (windowLocation.pathname === path) {
  54. // The browser is at the specified path already and what remains is
  55. // to make this App instance aware of the route to be rendered at
  56. // the current location.
  57. super._navigate(route);
  58. } else {
  59. // The browser must go to the specified location. Once the specified
  60. // location becomes current, the App will be made aware of the route
  61. // to be rendered at it.
  62. windowLocation.pathname = path;
  63. }
  64. }
  65. }