Skip to content

Commit

Permalink
Remove duplication, simplify, comply with coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
lyubomir committed Jan 10, 2017
1 parent b679942 commit 2f01746
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 301 deletions.
10 changes: 5 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ const APP = {
};

// TODO The execution of the mobile app starts from react/index.native.js.
// Similarly, the execution of the Web app should start from
// react/index.web.js for the sake of consistency and ease of understanding.
// Temporarily though because we are at the beginning of introducing React
// into the Web app, allow the execution of the Web app to start from app.js
// in order to reduce the complexity of the beginning step.
// Similarly, the execution of the Web app should start from react/index.web.js
// for the sake of consistency and ease of understanding. Temporarily though
// because we are at the beginning of introducing React into the Web app, allow
// the execution of the Web app to start from app.js in order to reduce the
// complexity of the beginning step.
require('./react');

module.exports = APP;
23 changes: 10 additions & 13 deletions react/features/app/actions.web.js → react/features/app/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ import {
} from './functions';
import './reducer';

/**
* Temporary solution. Should dispatch actions related to
* initial settings of the app like setting log levels,
* reading the config parameters from query string etc.
*
* @returns {Function}
*/
export function appInit() {
return () => init();
}

/**
* Triggers an in-app navigation to a different route. Allows navigation to be
Expand Down Expand Up @@ -91,19 +101,6 @@ export function appNavigate(urlOrRoom) {
};
}

/**
* Temporary solution. Should dispatch actions related to
* initial settings of the app like setting log levels,
* reading the config parameters from query string etc.
*
* @returns {Function}
*/
export function appInit() {
return () => {
init();
};
}

/**
* Signals that a specific App will mount (in the terms of React).
*
Expand Down
158 changes: 0 additions & 158 deletions react/features/app/actions.native.js

This file was deleted.

2 changes: 1 addition & 1 deletion react/features/app/components/AbstractApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AbstractApp extends Component {
* The URL, if any, with which the app was launched.
*/
url: React.PropTypes.string
};
}

/**
* Init lib-jitsi-meet and create local participant when component is going
Expand Down
72 changes: 35 additions & 37 deletions react/features/app/components/App.web.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/* global $ */
import React from 'react';
import { Provider } from 'react-redux';
import { compose } from 'redux';
import {
browserHistory,
Route,
Router
} from 'react-router';
import { push, syncHistoryWithStore } from 'react-router-redux';
import { compose } from 'redux';

import { getDomain } from '../../base/connection';
import { RouteRegistry } from '../../base/navigator';

import { AbstractApp } from './AbstractApp';
import { appInit } from '../actions';

import { AbstractApp } from './AbstractApp';

/**
* Root application component.
Expand All @@ -27,7 +26,7 @@ export class App extends AbstractApp {
*
* @static
*/
static propTypes = AbstractApp.propTypes;
static propTypes = AbstractApp.propTypes

/**
* Initializes a new App instance.
Expand All @@ -46,10 +45,10 @@ export class App extends AbstractApp {
this.history = syncHistoryWithStore(browserHistory, props.store);

// Bind event handlers so they are only bound once for every instance.
this._onRouteEnter = this._onRouteEnter.bind(this);
this._routerCreateElement = this._routerCreateElement.bind(this);
this._getRoute = this._getRoute.bind(this);
this._getRoutes = this._getRoutes.bind(this);
this._onRouteEnter = this._onRouteEnter.bind(this);
this._routerCreateElement = this._routerCreateElement.bind(this);
}

/**
Expand All @@ -59,6 +58,7 @@ export class App extends AbstractApp {
*/
componentWillMount(...args) {
super.componentWillMount(...args);

this.props.store.dispatch(appInit());
}

Expand All @@ -69,7 +69,6 @@ export class App extends AbstractApp {
* @returns {ReactElement}
*/
render() {

return (
<Provider store = { this.props.store }>
<Router
Expand All @@ -82,24 +81,23 @@ export class App extends AbstractApp {
}

/**
* Navigates to a specific Route (via platform-specific means).
* Method returns route for React Router.
*
* @param {Route} route - The Route to which to navigate.
* @returns {void}
* @param {Object} route - Object that describes route.
* @returns {ReactElement}
* @private
*/
_navigate(route) {
let path = route.path;
const store = this.props.store;

// 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);
_getRoute(route) {
const onEnter = route.onEnter || $.noop;
const handler = compose(this._onRouteEnter, onEnter);

return store.dispatch(push(path));
return (
<Route
component = { route.component }
key = { route.component }
onEnter = { handler }
path = { route.path } />
);
}

/**
Expand All @@ -115,23 +113,24 @@ export class App extends AbstractApp {
}

/**
* Method returns route for React Router.
* Navigates to a specific Route (via platform-specific means).
*
* @param {Object} route - Object that describes route.
* @returns {ReactElement}
* @private
* @param {Route} route - The Route to which to navigate.
* @returns {void}
*/
_getRoute(route) {
const onEnter = route.onEnter || $.noop;
const handler = compose(this._onRouteEnter, onEnter);
_navigate(route) {
let path = route.path;
const store = this.props.store;

return (
<Route
component = { route.component }
key = { route.component }
onEnter = { handler }
path = { route.path } />
);
// 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);

return store.dispatch(push(path));
}

/**
Expand All @@ -142,7 +141,6 @@ export class App extends AbstractApp {
* @returns {void}
*/
_onRouteEnter() {

// XXX The following is mandatory. Otherwise, moving back & forward
// through the browser's history could leave this App on the Conference
// page without a room name.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import React from 'react';

import JitsiMeetJS from './';
import {
LIB_DISPOSED,
Expand Down Expand Up @@ -40,6 +42,12 @@ export function initLib() {
throw new Error('Cannot initialize lib-jitsi-meet without config');
}

if (!React.View) {
// XXX Temporarily until conference.js is moved to the React app we
// shouldn't use JitsiMeetJS from the React app.
return Promise.resolve();
}

return JitsiMeetJS.init(config)
.then(() => dispatch({ type: LIB_INITIALIZED }))
.catch(error => {
Expand Down
Loading

0 comments on commit 2f01746

Please sign in to comment.