[RN] Use a default host when only a room name is specified

The mobile app remembers the domain which hosted the last conference. If
the user specified a full URL first and specified a room name only the
second time, it was not obvious that the second conference would be
hosted on the domain of the first conference.
This commit is contained in:
Lyubomir Marinov 2017-02-18 10:02:31 -06:00
parent 0dbbc5d8b6
commit d93bd3eda7
2 changed files with 25 additions and 19 deletions

View File

@ -24,16 +24,27 @@ export function appInit() {
* Triggers an in-app navigation to a different route. Allows navigation to be
* abstracted between the mobile and web versions.
*
* @param {(string|undefined)} urlOrRoom - The URL or room name to which to
* navigate.
* @param {(string|undefined)} uri - The URI to which to navigate. It may be a
* full URL with an http(s) scheme, a full or partial URI with the app-specific
* sheme, or a mere room name.
* @returns {Function}
*/
export function appNavigate(urlOrRoom) {
export function appNavigate(uri) {
return (dispatch, getState) => {
const state = getState();
const oldDomain = getDomain(state);
const { domain, room } = _parseURIString(urlOrRoom);
// eslint-disable-next-line prefer-const
let { domain, room } = _parseURIString(uri);
// If the specified URI does not identify a domain, use the app's
// default.
if (typeof domain === 'undefined') {
domain
= _parseURIString(state['features/app'].app._getDefaultURL())
.domain;
}
// TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
// currently in a conference and ask her if she wants to close the
@ -48,7 +59,7 @@ export function appNavigate(urlOrRoom) {
dispatch(setDomain(domain));
// If domain has changed, we need to load the config of the new
// domain and set it, and only after that we can navigate to
// domain and set it, and only after that we can navigate to a
// different route.
loadConfig(`https://${domain}`)
.then(
@ -92,7 +103,7 @@ export function appNavigate(urlOrRoom) {
dispatch(
_setRoomAndNavigate(
typeof room === 'undefined' && typeof domain === 'undefined'
? urlOrRoom
? uri
: room));
}
};

View File

@ -76,7 +76,9 @@ export class AbstractApp extends Component {
dispatch(localParticipantJoined());
this._openURL(this._getDefaultURL());
// If a URL was explicitly specified to this React Component, then open
// it; otherwise, use a default.
this._openURL(this.props.url || this._getDefaultURL());
}
/**
@ -211,27 +213,20 @@ export class AbstractApp extends Component {
/**
* Gets the default URL to be opened when this App mounts.
*
* @private
* @protected
* @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;
const href = windowLocation.toString();
if (href) {
return href;
}
}