Comply w/ coding style
This commit is contained in:
@@ -42,13 +42,7 @@ export function appNavigate(urlOrRoom) {
|
||||
// domain.
|
||||
|
||||
if (typeof domain === 'undefined' || oldDomain === domain) {
|
||||
// If both domain and room vars became undefined, that means we're
|
||||
// actually dealing with just room name and not with URL.
|
||||
dispatch(
|
||||
_setRoomAndNavigate(
|
||||
typeof room === 'undefined' && typeof domain === 'undefined'
|
||||
? urlOrRoom
|
||||
: room));
|
||||
dispatchSetRoomAndNavigate();
|
||||
} else if (oldDomain !== domain) {
|
||||
// Update domain without waiting for config to be loaded to prevent
|
||||
// race conditions when we will start to load config multiple times.
|
||||
@@ -61,14 +55,7 @@ export function appNavigate(urlOrRoom) {
|
||||
.then(
|
||||
config => configLoaded(/* err */ undefined, config),
|
||||
err => configLoaded(err, /* config */ undefined))
|
||||
.then(() => {
|
||||
const link = typeof room === 'undefined'
|
||||
&& typeof domain === 'undefined'
|
||||
? urlOrRoom
|
||||
: room;
|
||||
|
||||
dispatch(_setRoomAndNavigate(link));
|
||||
});
|
||||
.then(dispatchSetRoomAndNavigate);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +81,21 @@ export function appNavigate(urlOrRoom) {
|
||||
|
||||
dispatch(setConfig(config));
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches _setRoomAndNavigate in the Redux store.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function dispatchSetRoomAndNavigate() {
|
||||
// If both domain and room vars became undefined, that means we're
|
||||
// actually dealing with just room name and not with URL.
|
||||
dispatch(
|
||||
_setRoomAndNavigate(
|
||||
typeof room === 'undefined' && typeof domain === 'undefined'
|
||||
? urlOrRoom
|
||||
: room));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -129,6 +131,21 @@ export function appWillUnmount(app) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigates to a route in accord with a specific Redux state.
|
||||
*
|
||||
* @param {Object} state - The Redux state which determines/identifies the route
|
||||
* to navigate to.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function _navigate(state) {
|
||||
const app = state['features/app'].app;
|
||||
const routeToRender = _getRouteToRender(state);
|
||||
|
||||
app._navigate(routeToRender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets room and navigates to new route if needed.
|
||||
*
|
||||
@@ -139,11 +156,6 @@ export function appWillUnmount(app) {
|
||||
function _setRoomAndNavigate(newRoom) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch(setRoom(newRoom));
|
||||
|
||||
const state = getState();
|
||||
const { app } = state['features/app'];
|
||||
const newRoute = _getRouteToRender(state);
|
||||
|
||||
app._navigate(newRoute);
|
||||
_navigate(getState());
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
import { RouteRegistry } from '../../base/navigator';
|
||||
import {
|
||||
localParticipantJoined,
|
||||
localParticipantLeft
|
||||
} from '../../base/participants';
|
||||
import { RouteRegistry } from '../../base/navigator';
|
||||
|
||||
import {
|
||||
appNavigate,
|
||||
@@ -32,7 +32,7 @@ export class AbstractApp extends Component {
|
||||
* The URL, if any, with which the app was launched.
|
||||
*/
|
||||
url: React.PropTypes.string
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new App instance.
|
||||
@@ -211,38 +211,37 @@ export class AbstractApp extends Component {
|
||||
* @returns {void}
|
||||
*/
|
||||
_navigate(route) {
|
||||
const currentRoute = this.state.route || {};
|
||||
|
||||
if (!RouteRegistry.areRoutesEqual(route, currentRoute)) {
|
||||
let nextState = {
|
||||
...this.state,
|
||||
route
|
||||
};
|
||||
|
||||
// The Web App was using react-router so it utilized react-router's
|
||||
// onEnter. During the removal of react-router, modifications were
|
||||
// minimized by preserving the onEnter interface:
|
||||
// (1) Router would provide its nextState to the Route's onEnter.
|
||||
// As the role of Router is now this AbstractApp, provide its
|
||||
// nextState.
|
||||
// (2) A replace function would be provided to the Route in case it
|
||||
// chose to redirect to another path.
|
||||
this._onRouteEnter(route, nextState, pathname => {
|
||||
// FIXME In order to minimize the modifications related to the
|
||||
// removal of react-router, the Web implementation is provided
|
||||
// bellow because the replace function is used on Web only at
|
||||
// the time of this writing. Provide a platform-agnostic
|
||||
// implementation. It should likely find the best Route matching
|
||||
// the specified pathname and navigate to it.
|
||||
window.location.pathname = pathname;
|
||||
|
||||
// Do not proceed with the route because it chose to redirect to
|
||||
// another path.
|
||||
nextState = undefined;
|
||||
});
|
||||
|
||||
nextState && this.setState(nextState);
|
||||
if (RouteRegistry.areRoutesEqual(this.state.route, route)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let nextState = {
|
||||
...this.state,
|
||||
route
|
||||
};
|
||||
|
||||
// The Web App was using react-router so it utilized react-router's
|
||||
// onEnter. During the removal of react-router, modifications were
|
||||
// minimized by preserving the onEnter interface:
|
||||
// (1) Router would provide its nextState to the Route's onEnter. As the
|
||||
// role of Router is now this AbstractApp, provide its nextState.
|
||||
// (2) A replace function would be provided to the Route in case it
|
||||
// chose to redirect to another path.
|
||||
this._onRouteEnter(route, nextState, pathname => {
|
||||
// FIXME In order to minimize the modifications related to the
|
||||
// removal of react-router, the Web implementation is provided
|
||||
// bellow because the replace function is used on Web only at the
|
||||
// time of this writing. Provide a platform-agnostic implementation.
|
||||
// It should likely find the best Route matching the specified
|
||||
// pathname and navigate to it.
|
||||
window.location.pathname = pathname;
|
||||
|
||||
// Do not proceed with the route because it chose to redirect to
|
||||
// another path.
|
||||
nextState = undefined;
|
||||
});
|
||||
|
||||
nextState && this.setState(nextState);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user