From d93bd3eda7bb056bc947f3b1fdb4bb91dcfbf505 Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Sat, 18 Feb 2017 10:02:31 -0600 Subject: [PATCH] [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. --- react/features/app/actions.js | 23 +++++++++++++++----- react/features/app/components/AbstractApp.js | 21 +++++++----------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/react/features/app/actions.js b/react/features/app/actions.js index a2898cad4..26a995c1a 100644 --- a/react/features/app/actions.js +++ b/react/features/app/actions.js @@ -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)); } }; diff --git a/react/features/app/components/AbstractApp.js b/react/features/app/components/AbstractApp.js index 787cdb567..a2d507077 100644 --- a/react/features/app/components/AbstractApp.js +++ b/react/features/app/components/AbstractApp.js @@ -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; } }