Преглед на файлове

[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.
j8
Lyubomir Marinov преди 8 години
родител
ревизия
d93bd3eda7
променени са 2 файла, в които са добавени 25 реда и са изтрити 19 реда
  1. 17
    6
      react/features/app/actions.js
  2. 8
    13
      react/features/app/components/AbstractApp.js

+ 17
- 6
react/features/app/actions.js Целия файл

@@ -24,16 +24,27 @@ export function appInit() {
24 24
  * Triggers an in-app navigation to a different route. Allows navigation to be
25 25
  * abstracted between the mobile and web versions.
26 26
  *
27
- * @param {(string|undefined)} urlOrRoom - The URL or room name to which to
28
- * navigate.
27
+ * @param {(string|undefined)} uri - The URI to which to navigate. It may be a
28
+ * full URL with an http(s) scheme, a full or partial URI with the app-specific
29
+ * sheme, or a mere room name.
29 30
  * @returns {Function}
30 31
  */
31
-export function appNavigate(urlOrRoom) {
32
+export function appNavigate(uri) {
32 33
     return (dispatch, getState) => {
33 34
         const state = getState();
34 35
         const oldDomain = getDomain(state);
35 36
 
36
-        const { domain, room } = _parseURIString(urlOrRoom);
37
+        // eslint-disable-next-line prefer-const
38
+        let { domain, room } = _parseURIString(uri);
39
+
40
+        // If the specified URI does not identify a domain, use the app's
41
+        // default.
42
+        if (typeof domain === 'undefined') {
43
+            domain
44
+                = _parseURIString(state['features/app'].app._getDefaultURL())
45
+                    .domain;
46
+
47
+        }
37 48
 
38 49
         // TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
39 50
         // currently in a conference and ask her if she wants to close the
@@ -48,7 +59,7 @@ export function appNavigate(urlOrRoom) {
48 59
             dispatch(setDomain(domain));
49 60
 
50 61
             // If domain has changed, we need to load the config of the new
51
-            // domain and set it, and only after that we can navigate to
62
+            // domain and set it, and only after that we can navigate to a
52 63
             // different route.
53 64
             loadConfig(`https://${domain}`)
54 65
                 .then(
@@ -92,7 +103,7 @@ export function appNavigate(urlOrRoom) {
92 103
             dispatch(
93 104
                 _setRoomAndNavigate(
94 105
                     typeof room === 'undefined' && typeof domain === 'undefined'
95
-                        ? urlOrRoom
106
+                        ? uri
96 107
                         : room));
97 108
         }
98 109
     };

+ 8
- 13
react/features/app/components/AbstractApp.js Целия файл

@@ -76,7 +76,9 @@ export class AbstractApp extends Component {
76 76
 
77 77
         dispatch(localParticipantJoined());
78 78
 
79
-        this._openURL(this._getDefaultURL());
79
+        // If a URL was explicitly specified to this React Component, then open
80
+        // it; otherwise, use a default.
81
+        this._openURL(this.props.url || this._getDefaultURL());
80 82
     }
81 83
 
82 84
     /**
@@ -211,27 +213,20 @@ export class AbstractApp extends Component {
211 213
     /**
212 214
      * Gets the default URL to be opened when this App mounts.
213 215
      *
214
-     * @private
216
+     * @protected
215 217
      * @returns {string} The default URL to be opened when this App mounts.
216 218
      */
217 219
     _getDefaultURL() {
218
-        // If the URL was explicitly specified to the React Component, then open
219
-        // it.
220
-        let url = this.props.url;
221
-
222
-        if (url) {
223
-            return url;
224
-        }
225
-
226 220
         // If the execution environment provides a Location abstraction, then
227 221
         // this App at already at that location but it must be made aware of the
228 222
         // fact.
229 223
         const windowLocation = this._getWindowLocation();
230 224
 
231 225
         if (windowLocation) {
232
-            url = windowLocation.toString();
233
-            if (url) {
234
-                return url;
226
+            const href = windowLocation.toString();
227
+
228
+            if (href) {
229
+                return href;
235 230
             }
236 231
         }
237 232
 

Loading…
Отказ
Запис