Preserve URLs
This commit is contained in:
parent
5f21e4c5b6
commit
856732abab
|
@ -11,18 +11,6 @@ import {
|
||||||
appWillUnmount
|
appWillUnmount
|
||||||
} from '../actions';
|
} from '../actions';
|
||||||
|
|
||||||
/**
|
|
||||||
* Default config.
|
|
||||||
*
|
|
||||||
* @type {Object}
|
|
||||||
*/
|
|
||||||
const DEFAULT_CONFIG = {
|
|
||||||
configLocation: './config.js',
|
|
||||||
hosts: {
|
|
||||||
domain: 'meet.jit.si'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base (abstract) class for main App component.
|
* Base (abstract) class for main App component.
|
||||||
*
|
*
|
||||||
|
@ -57,12 +45,7 @@ export class AbstractApp extends Component {
|
||||||
|
|
||||||
dispatch(localParticipantJoined());
|
dispatch(localParticipantJoined());
|
||||||
|
|
||||||
const config
|
this._openURL(this._getDefaultURL());
|
||||||
= typeof this.props.config === 'object'
|
|
||||||
? this.props.config
|
|
||||||
: DEFAULT_CONFIG;
|
|
||||||
|
|
||||||
this._openURL(this.props.url || `https://${config.hosts.domain}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,6 +99,68 @@ export class AbstractApp extends Component {
|
||||||
return React.createElement(component, { ...thisProps, ...props });
|
return React.createElement(component, { ...thisProps, ...props });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default URL to be opened when this App mounts.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @returns {string} The default URL to be opened when this App mounts.
|
||||||
|
*/
|
||||||
|
_getDefaultURL() {
|
||||||
|
// If the URL was explicitly specified to the React Component, then open
|
||||||
|
// it.
|
||||||
|
let url = this.props.url;
|
||||||
|
|
||||||
|
if (url) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the execution environment provides a Location abstraction, then
|
||||||
|
// this App at already at that location but it must be made aware of the
|
||||||
|
// fact.
|
||||||
|
const windowLocation = this._getWindowLocation();
|
||||||
|
|
||||||
|
if (windowLocation) {
|
||||||
|
url = windowLocation.toString();
|
||||||
|
if (url) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// By default, open the domain configured in the configuration file
|
||||||
|
// which may be the domain at which the whole server infrastructure is
|
||||||
|
// deployed.
|
||||||
|
const config = this.props.config;
|
||||||
|
|
||||||
|
if (typeof config === 'object') {
|
||||||
|
const hosts = config.hosts;
|
||||||
|
|
||||||
|
if (typeof hosts === 'object') {
|
||||||
|
const domain = hosts.domain;
|
||||||
|
|
||||||
|
if (domain) {
|
||||||
|
return `https://${domain}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'https://meet.jit.si';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a Location object from the window with information about the current
|
||||||
|
* location of the document. Explicitly defined to allow extenders to
|
||||||
|
* override because React Native does not usually have a location property
|
||||||
|
* on its window unless debugging remotely in which case the browser that is
|
||||||
|
* the remote debugger will provide a location property on the window.
|
||||||
|
*
|
||||||
|
* @protected
|
||||||
|
* @returns {Location} A Location object with information about the current
|
||||||
|
* location of the document.
|
||||||
|
*/
|
||||||
|
_getWindowLocation() {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigates this AbstractApp to (i.e. opens) a specific URL.
|
* Navigates this AbstractApp to (i.e. opens) a specific URL.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { browserHistory, Route, Router } from 'react-router';
|
import { browserHistory, Route, Router } from 'react-router';
|
||||||
import { push, syncHistoryWithStore } from 'react-router-redux';
|
import { push, replace, syncHistoryWithStore } from 'react-router-redux';
|
||||||
|
|
||||||
import { getDomain } from '../../base/connection';
|
|
||||||
import { RouteRegistry } from '../../base/navigator';
|
import { RouteRegistry } from '../../base/navigator';
|
||||||
|
|
||||||
import { appInit } from '../actions';
|
import { appInit } from '../actions';
|
||||||
|
@ -73,6 +72,16 @@ export class App extends AbstractApp {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a Location object from the window with information about the current
|
||||||
|
* location of the document.
|
||||||
|
*
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
_getWindowLocation() {
|
||||||
|
return window.location;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigates to a specific Route (via platform-specific means).
|
* Navigates to a specific Route (via platform-specific means).
|
||||||
*
|
*
|
||||||
|
@ -91,7 +100,10 @@ export class App extends AbstractApp {
|
||||||
/:room/g,
|
/:room/g,
|
||||||
store.getState()['features/base/conference'].room);
|
store.getState()['features/base/conference'].room);
|
||||||
|
|
||||||
return store.dispatch(push(path));
|
return (
|
||||||
|
store.dispatch(
|
||||||
|
(window.location.pathname === path ? replace : push)(
|
||||||
|
path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -117,15 +129,7 @@ export class App extends AbstractApp {
|
||||||
// Our Router configuration (at the time of this writing) is such that
|
// Our Router configuration (at the time of this writing) is such that
|
||||||
// each Route corresponds to a single URL. Hence, entering into a Route
|
// each Route corresponds to a single URL. Hence, entering into a Route
|
||||||
// is like opening a URL.
|
// is like opening a URL.
|
||||||
|
this._openURL(window.location.toString());
|
||||||
// XXX In order to unify work with URLs in web and native environments,
|
|
||||||
// we will construct URL here with correct domain from config.
|
|
||||||
const currentDomain = getDomain(this.props.store.getState);
|
|
||||||
const url
|
|
||||||
= new URL(window.location.pathname, `https://${currentDomain}`)
|
|
||||||
.toString();
|
|
||||||
|
|
||||||
this._openURL(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -182,7 +182,11 @@ export function createConference() {
|
||||||
|
|
||||||
// TODO Take options from config.
|
// TODO Take options from config.
|
||||||
const conference
|
const conference
|
||||||
= connection.initJitsiConference(room, { openSctp: true });
|
= connection.initJitsiConference(
|
||||||
|
|
||||||
|
// XXX Lib-jitsi-meet does not accept uppercase letters.
|
||||||
|
room.toLowerCase(),
|
||||||
|
{ openSctp: true });
|
||||||
|
|
||||||
_addConferenceListeners(conference, dispatch);
|
_addConferenceListeners(conference, dispatch);
|
||||||
|
|
||||||
|
|
|
@ -245,10 +245,7 @@ function _setPassword(state, action) {
|
||||||
function _setRoom(state, action) {
|
function _setRoom(state, action) {
|
||||||
let room = action.room;
|
let room = action.room;
|
||||||
|
|
||||||
if (isRoomValid(room)) {
|
if (!isRoomValid(room)) {
|
||||||
// XXX Lib-jitsi-meet does not accept uppercase letters.
|
|
||||||
room = room.toLowerCase();
|
|
||||||
} else {
|
|
||||||
// Technically, there are multiple values which don't represent valid
|
// Technically, there are multiple values which don't represent valid
|
||||||
// room names. Practically, each of them is as bad as the rest of them
|
// room names. Practically, each of them is as bad as the rest of them
|
||||||
// because we can't use any of them to join a conference.
|
// because we can't use any of them to join a conference.
|
||||||
|
|
|
@ -16,7 +16,9 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
|
||||||
export function connect() {
|
export function connect() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const room = state['features/base/conference'].room;
|
|
||||||
|
// XXX Lib-jitsi-meet does not accept uppercase letters.
|
||||||
|
const room = state['features/base/conference'].room.toLowerCase();
|
||||||
|
|
||||||
// XXX For web based version we use conference initialization logic
|
// XXX For web based version we use conference initialization logic
|
||||||
// from the old app (at the moment of writing).
|
// from the old app (at the moment of writing).
|
||||||
|
|
|
@ -56,8 +56,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<App
|
<App
|
||||||
config = { config }
|
config = { config }
|
||||||
store = { store }
|
store = { store } />,
|
||||||
url = { window.location.toString() } />,
|
|
||||||
document.getElementById('react'));
|
document.getElementById('react'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue