Kaynağa Gözat

Preserve URLs

master
Lyubomir Marinov 9 yıl önce
ebeveyn
işleme
856732abab

+ 63
- 18
react/features/app/components/AbstractApp.js Dosyayı Görüntüle

@@ -11,18 +11,6 @@ import {
11 11
     appWillUnmount
12 12
 } from '../actions';
13 13
 
14
-/**
15
- * Default config.
16
- *
17
- * @type {Object}
18
- */
19
-const DEFAULT_CONFIG = {
20
-    configLocation: './config.js',
21
-    hosts: {
22
-        domain: 'meet.jit.si'
23
-    }
24
-};
25
-
26 14
 /**
27 15
  * Base (abstract) class for main App component.
28 16
  *
@@ -57,12 +45,7 @@ export class AbstractApp extends Component {
57 45
 
58 46
         dispatch(localParticipantJoined());
59 47
 
60
-        const config
61
-            = typeof this.props.config === 'object'
62
-                ? this.props.config
63
-                : DEFAULT_CONFIG;
64
-
65
-        this._openURL(this.props.url || `https://${config.hosts.domain}`);
48
+        this._openURL(this._getDefaultURL());
66 49
     }
67 50
 
68 51
     /**
@@ -116,6 +99,68 @@ export class AbstractApp extends Component {
116 99
         return React.createElement(component, { ...thisProps, ...props });
117 100
     }
118 101
 
102
+    /**
103
+     * Gets the default URL to be opened when this App mounts.
104
+     *
105
+     * @private
106
+     * @returns {string} The default URL to be opened when this App mounts.
107
+     */
108
+    _getDefaultURL() {
109
+        // If the URL was explicitly specified to the React Component, then open
110
+        // it.
111
+        let url = this.props.url;
112
+
113
+        if (url) {
114
+            return url;
115
+        }
116
+
117
+        // If the execution environment provides a Location abstraction, then
118
+        // this App at already at that location but it must be made aware of the
119
+        // fact.
120
+        const windowLocation = this._getWindowLocation();
121
+
122
+        if (windowLocation) {
123
+            url = windowLocation.toString();
124
+            if (url) {
125
+                return url;
126
+            }
127
+        }
128
+
129
+        // By default, open the domain configured in the configuration file
130
+        // which may be the domain at which the whole server infrastructure is
131
+        // deployed.
132
+        const config = this.props.config;
133
+
134
+        if (typeof config === 'object') {
135
+            const hosts = config.hosts;
136
+
137
+            if (typeof hosts === 'object') {
138
+                const domain = hosts.domain;
139
+
140
+                if (domain) {
141
+                    return `https://${domain}`;
142
+                }
143
+            }
144
+        }
145
+
146
+        return 'https://meet.jit.si';
147
+    }
148
+
149
+    /**
150
+     * Gets a Location object from the window with information about the current
151
+     * location of the document. Explicitly defined to allow extenders to
152
+     * override because React Native does not usually have a location property
153
+     * on its window unless debugging remotely in which case the browser that is
154
+     * the remote debugger will provide a location property on the window.
155
+     *
156
+     * @protected
157
+     * @returns {Location} A Location object with information about the current
158
+     * location of the document.
159
+     */
160
+    _getWindowLocation() {
161
+        return undefined;
162
+    }
163
+
119 164
     /**
120 165
      * Navigates this AbstractApp to (i.e. opens) a specific URL.
121 166
      *

+ 16
- 12
react/features/app/components/App.web.js Dosyayı Görüntüle

@@ -1,9 +1,8 @@
1 1
 import React from 'react';
2 2
 import { Provider } from 'react-redux';
3 3
 import { browserHistory, Route, Router } from 'react-router';
4
-import { push, syncHistoryWithStore } from 'react-router-redux';
4
+import { push, replace, syncHistoryWithStore } from 'react-router-redux';
5 5
 
6
-import { getDomain } from '../../base/connection';
7 6
 import { RouteRegistry } from '../../base/navigator';
8 7
 
9 8
 import { appInit } from '../actions';
@@ -73,6 +72,16 @@ export class App extends AbstractApp {
73 72
         );
74 73
     }
75 74
 
75
+    /**
76
+     * Gets a Location object from the window with information about the current
77
+     * location of the document.
78
+     *
79
+     * @inheritdoc
80
+     */
81
+    _getWindowLocation() {
82
+        return window.location;
83
+    }
84
+
76 85
     /**
77 86
      * Navigates to a specific Route (via platform-specific means).
78 87
      *
@@ -91,7 +100,10 @@ export class App extends AbstractApp {
91 100
                 /:room/g,
92 101
                 store.getState()['features/base/conference'].room);
93 102
 
94
-        return store.dispatch(push(path));
103
+        return (
104
+            store.dispatch(
105
+                    (window.location.pathname === path ? replace : push)(
106
+                            path)));
95 107
     }
96 108
 
97 109
     /**
@@ -117,15 +129,7 @@ export class App extends AbstractApp {
117 129
         // Our Router configuration (at the time of this writing) is such that
118 130
         // each Route corresponds to a single URL. Hence, entering into a Route
119 131
         // is like opening a URL.
120
-
121
-        // XXX In order to unify work with URLs in web and native environments,
122
-        // we will construct URL here with correct domain from config.
123
-        const currentDomain = getDomain(this.props.store.getState);
124
-        const url
125
-            = new URL(window.location.pathname, `https://${currentDomain}`)
126
-                .toString();
127
-
128
-        this._openURL(url);
132
+        this._openURL(window.location.toString());
129 133
     }
130 134
 
131 135
     /**

+ 5
- 1
react/features/base/conference/actions.js Dosyayı Görüntüle

@@ -182,7 +182,11 @@ export function createConference() {
182 182
 
183 183
         // TODO Take options from config.
184 184
         const conference
185
-            = connection.initJitsiConference(room, { openSctp: true });
185
+            = connection.initJitsiConference(
186
+
187
+                    // XXX Lib-jitsi-meet does not accept uppercase letters.
188
+                    room.toLowerCase(),
189
+                    { openSctp: true });
186 190
 
187 191
         _addConferenceListeners(conference, dispatch);
188 192
 

+ 1
- 4
react/features/base/conference/reducer.js Dosyayı Görüntüle

@@ -245,10 +245,7 @@ function _setPassword(state, action) {
245 245
 function _setRoom(state, action) {
246 246
     let room = action.room;
247 247
 
248
-    if (isRoomValid(room)) {
249
-        // XXX Lib-jitsi-meet does not accept uppercase letters.
250
-        room = room.toLowerCase();
251
-    } else {
248
+    if (!isRoomValid(room)) {
252 249
         // Technically, there are multiple values which don't represent valid
253 250
         // room names. Practically, each of them is as bad as the rest of them
254 251
         // because we can't use any of them to join a conference.

+ 3
- 1
react/features/base/connection/actions.web.js Dosyayı Görüntüle

@@ -16,7 +16,9 @@ const logger = require('jitsi-meet-logger').getLogger(__filename);
16 16
 export function connect() {
17 17
     return (dispatch, getState) => {
18 18
         const state = getState();
19
-        const room = state['features/base/conference'].room;
19
+
20
+        // XXX Lib-jitsi-meet does not accept uppercase letters.
21
+        const room = state['features/base/conference'].room.toLowerCase();
20 22
 
21 23
         // XXX For web based version we use conference initialization logic
22 24
         // from the old app (at the moment of writing).

+ 1
- 2
react/index.web.js Dosyayı Görüntüle

@@ -56,8 +56,7 @@ document.addEventListener('DOMContentLoaded', () => {
56 56
     ReactDOM.render(
57 57
         <App
58 58
             config = { config }
59
-            store = { store }
60
-            url = { window.location.toString() } />,
59
+            store = { store } />,
61 60
         document.getElementById('react'));
62 61
 });
63 62
 

Loading…
İptal
Kaydet