2017-01-15 04:05:56 +00:00
|
|
|
import { appInit } from '../actions';
|
2017-01-10 19:06:18 +00:00
|
|
|
import { AbstractApp } from './AbstractApp';
|
2016-12-14 10:32:36 +00:00
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
/**
|
|
|
|
* Root application component.
|
|
|
|
*
|
|
|
|
* @extends AbstractApp
|
|
|
|
*/
|
|
|
|
export class App extends AbstractApp {
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
|
|
|
* App component's property types.
|
|
|
|
*
|
|
|
|
* @static
|
|
|
|
*/
|
2017-01-10 19:06:18 +00:00
|
|
|
static propTypes = AbstractApp.propTypes
|
2016-12-01 01:52:39 +00:00
|
|
|
|
2016-11-23 21:46:46 +00:00
|
|
|
/**
|
2016-12-14 12:09:29 +00:00
|
|
|
* Inits the app before component will mount.
|
2016-11-23 21:46:46 +00:00
|
|
|
*
|
2016-12-12 21:13:17 +00:00
|
|
|
* @inheritdoc
|
2016-11-23 21:46:46 +00:00
|
|
|
*/
|
2016-12-12 21:13:17 +00:00
|
|
|
componentWillMount(...args) {
|
|
|
|
super.componentWillMount(...args);
|
2017-01-10 19:06:18 +00:00
|
|
|
|
2016-12-14 12:09:29 +00:00
|
|
|
this.props.store.dispatch(appInit());
|
2016-11-23 21:46:46 +00:00
|
|
|
}
|
|
|
|
|
2017-01-15 19:05:17 +00:00
|
|
|
/**
|
|
|
|
* Gets a Location object from the window with information about the current
|
|
|
|
* location of the document.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
_getWindowLocation() {
|
|
|
|
return window.location;
|
|
|
|
}
|
|
|
|
|
2016-12-12 21:13:17 +00:00
|
|
|
/**
|
2017-01-10 19:06:18 +00:00
|
|
|
* Navigates to a specific Route (via platform-specific means).
|
2016-12-12 21:13:17 +00:00
|
|
|
*
|
2017-01-10 19:06:18 +00:00
|
|
|
* @param {Route} route - The Route to which to navigate.
|
2017-01-16 00:28:02 +00:00
|
|
|
* @protected
|
2017-01-10 19:06:18 +00:00
|
|
|
* @returns {void}
|
2016-12-12 21:13:17 +00:00
|
|
|
*/
|
2017-01-10 19:06:18 +00:00
|
|
|
_navigate(route) {
|
|
|
|
let path = route.path;
|
|
|
|
const store = this.props.store;
|
2016-12-12 21:13:17 +00:00
|
|
|
|
2017-01-10 19:06:18 +00:00
|
|
|
// The syntax :room bellow is defined by react-router. It "matches a URL
|
|
|
|
// segment up to the next /, ?, or #. The matched string is called a
|
|
|
|
// param."
|
|
|
|
path
|
|
|
|
= path.replace(
|
|
|
|
/:room/g,
|
|
|
|
store.getState()['features/base/conference'].room);
|
|
|
|
|
2017-01-16 00:28:02 +00:00
|
|
|
// Navigate to the specified Route.
|
|
|
|
const windowLocation = this._getWindowLocation();
|
|
|
|
|
|
|
|
if (windowLocation.pathname === path) {
|
|
|
|
// The browser is at the specified path already and what remains is
|
|
|
|
// to make this App instance aware of the route to be rendered at
|
|
|
|
// the current location.
|
|
|
|
super._navigate(route);
|
|
|
|
} else {
|
|
|
|
// The browser must go to the specified location. Once the specified
|
|
|
|
// location becomes current, the App will be made aware of the route
|
|
|
|
// to be rendered at it.
|
|
|
|
windowLocation.pathname = path;
|
2017-01-10 21:55:31 +00:00
|
|
|
}
|
2016-11-23 21:46:46 +00:00
|
|
|
}
|
|
|
|
}
|