|
@@ -39,22 +39,11 @@ export function appNavigate(uri: ?string) {
|
39
|
39
|
function _appNavigateToMandatoryLocation(
|
40
|
40
|
dispatch: Dispatch<*>, getState: Function,
|
41
|
41
|
newLocation: Object) {
|
42
|
|
- const oldLocationURL = getState()['features/base/connection'].locationURL;
|
43
|
|
- const oldHost = oldLocationURL ? oldLocationURL.host : undefined;
|
44
|
|
- const newHost = newLocation.host;
|
45
|
|
-
|
46
|
|
- if (oldHost === newHost) {
|
47
|
|
- dispatchSetLocationURL()
|
48
|
|
- .then(dispatchSetRoom);
|
49
|
|
- } else {
|
50
|
|
- // If the host has changed, we need to load the config of the new host
|
51
|
|
- // and set it, and only after that we can navigate to a different route.
|
52
|
|
- _loadConfig(newLocation)
|
53
|
|
- .then(
|
54
|
|
- config => configLoaded(/* err */ undefined, config),
|
55
|
|
- err => configLoaded(err, /* config */ undefined))
|
56
|
|
- .then(dispatchSetRoom);
|
57
|
|
- }
|
|
42
|
+ _loadConfig(newLocation)
|
|
43
|
+ .then(
|
|
44
|
+ config => configLoaded(/* err */ undefined, config),
|
|
45
|
+ err => configLoaded(err, /* config */ undefined))
|
|
46
|
+ .then(() => dispatch(setRoom(newLocation.room)));
|
58
|
47
|
|
59
|
48
|
/**
|
60
|
49
|
* Notifies that an attempt to load a config(uration) has completed. Due to
|
|
@@ -83,27 +72,9 @@ function _appNavigateToMandatoryLocation(
|
83
|
72
|
}
|
84
|
73
|
|
85
|
74
|
return (
|
86
|
|
- dispatchSetLocationURL()
|
|
75
|
+ dispatch(setLocationURL(new URL(newLocation.toString())))
|
87
|
76
|
.then(() => dispatch(setConfig(config))));
|
88
|
77
|
}
|
89
|
|
-
|
90
|
|
- /**
|
91
|
|
- * Dispatches {@link setLocationURL} in the redux store.
|
92
|
|
- *
|
93
|
|
- * @returns {void}
|
94
|
|
- */
|
95
|
|
- function dispatchSetLocationURL() {
|
96
|
|
- return dispatch(setLocationURL(new URL(newLocation.toString())));
|
97
|
|
- }
|
98
|
|
-
|
99
|
|
- /**
|
100
|
|
- * Dispatches {@link _setRoomAndNavigate} in the redux store.
|
101
|
|
- *
|
102
|
|
- * @returns {void}
|
103
|
|
- */
|
104
|
|
- function dispatchSetRoom() {
|
105
|
|
- return dispatch(setRoom(newLocation.room));
|
106
|
|
- }
|
107
|
78
|
}
|
108
|
79
|
|
109
|
80
|
/**
|
|
@@ -196,8 +167,10 @@ export function appWillUnmount(app) {
|
196
|
167
|
* @private
|
197
|
168
|
* @returns {Promise<Object>}
|
198
|
169
|
*/
|
199
|
|
-function _loadConfig(location: Object) {
|
200
|
|
- let protocol = location.protocol.toLowerCase();
|
|
170
|
+function _loadConfig({ contextRoot, host, protocol, room }) {
|
|
171
|
+ /* eslint-disable no-param-reassign */
|
|
172
|
+
|
|
173
|
+ protocol = protocol.toLowerCase();
|
201
|
174
|
|
202
|
175
|
// The React Native app supports an app-specific scheme which is sure to not
|
203
|
176
|
// be supported by fetch (or whatever loadConfig utilizes).
|
|
@@ -205,7 +178,12 @@ function _loadConfig(location: Object) {
|
205
|
178
|
|
206
|
179
|
// TDOO userinfo
|
207
|
180
|
|
208
|
|
- return (
|
209
|
|
- loadConfig(
|
210
|
|
- `${protocol}//${location.host}${location.contextRoot || '/'}`));
|
|
181
|
+ let url = `${protocol}//${host}${contextRoot || '/'}config.js`;
|
|
182
|
+
|
|
183
|
+ // XXX In order to support multiple shards, tell the room to the deployment.
|
|
184
|
+ room && (url += `?room=${room.toLowerCase()}`);
|
|
185
|
+
|
|
186
|
+ /* eslint-enable no-param-reassign */
|
|
187
|
+
|
|
188
|
+ return loadConfig(url);
|
211
|
189
|
}
|