Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

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

Lyubomir Marinovd93bd3eda7bb
diff --git a/react/features/app/actions.js b/react/features/app/actions.js
index a2898cad4f..26a995c1a4 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 787cdb567e..a2d5070770 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;
}
}