浏览代码

[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
  * Triggers an in-app navigation to a different route. Allows navigation to be
24
  * Triggers an in-app navigation to a different route. Allows navigation to be
25
  * abstracted between the mobile and web versions.
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
  * @returns {Function}
30
  * @returns {Function}
30
  */
31
  */
31
-export function appNavigate(urlOrRoom) {
32
+export function appNavigate(uri) {
32
     return (dispatch, getState) => {
33
     return (dispatch, getState) => {
33
         const state = getState();
34
         const state = getState();
34
         const oldDomain = getDomain(state);
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
         // TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
49
         // TODO Kostiantyn Tsaregradskyi: We should probably detect if user is
39
         // currently in a conference and ask her if she wants to close the
50
         // currently in a conference and ask her if she wants to close the
48
             dispatch(setDomain(domain));
59
             dispatch(setDomain(domain));
49
 
60
 
50
             // If domain has changed, we need to load the config of the new
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
             // different route.
63
             // different route.
53
             loadConfig(`https://${domain}`)
64
             loadConfig(`https://${domain}`)
54
                 .then(
65
                 .then(
92
             dispatch(
103
             dispatch(
93
                 _setRoomAndNavigate(
104
                 _setRoomAndNavigate(
94
                     typeof room === 'undefined' && typeof domain === 'undefined'
105
                     typeof room === 'undefined' && typeof domain === 'undefined'
95
-                        ? urlOrRoom
106
+                        ? uri
96
                         : room));
107
                         : room));
97
         }
108
         }
98
     };
109
     };

+ 8
- 13
react/features/app/components/AbstractApp.js 查看文件

76
 
76
 
77
         dispatch(localParticipantJoined());
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
     /**
213
     /**
212
      * Gets the default URL to be opened when this App mounts.
214
      * Gets the default URL to be opened when this App mounts.
213
      *
215
      *
214
-     * @private
216
+     * @protected
215
      * @returns {string} The default URL to be opened when this App mounts.
217
      * @returns {string} The default URL to be opened when this App mounts.
216
      */
218
      */
217
     _getDefaultURL() {
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
         // If the execution environment provides a Location abstraction, then
220
         // If the execution environment provides a Location abstraction, then
227
         // this App at already at that location but it must be made aware of the
221
         // this App at already at that location but it must be made aware of the
228
         // fact.
222
         // fact.
229
         const windowLocation = this._getWindowLocation();
223
         const windowLocation = this._getWindowLocation();
230
 
224
 
231
         if (windowLocation) {
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
 

正在加载...
取消
保存