|
@@ -96,51 +96,53 @@ export function overwriteConfig(config: Object) {
|
96
|
96
|
*
|
97
|
97
|
* @param {Object} config - The configuration to be represented by the feature
|
98
|
98
|
* base/config.
|
99
|
|
- * @param {URL} locationURL - The URL of the location which necessitated the
|
100
|
|
- * loading of a configuration.
|
101
|
99
|
* @returns {Function}
|
102
|
100
|
*/
|
103
|
|
-export function setConfig(config: IConfig = {}, locationURL: URL | undefined) {
|
104
|
|
- // Now that the loading of the config was successful override the values
|
105
|
|
- // with the parameters passed in the hash part of the location URI.
|
106
|
|
- // TODO We're still in the middle ground between old Web with config,
|
107
|
|
- // and interfaceConfig used via global variables and new
|
108
|
|
- // Web and mobile reading the respective values from the redux store.
|
109
|
|
- // Only the config will be overridden on React Native, as the other
|
110
|
|
- // globals will be undefined here. It's intentional - we do not care to
|
111
|
|
- // override those configs yet.
|
112
|
|
- locationURL
|
113
|
|
- && setConfigFromURLParams(
|
114
|
|
-
|
115
|
|
- // On Web the config also comes from the window.config global,
|
116
|
|
- // but it is resolved in the loadConfig procedure.
|
117
|
|
- config,
|
118
|
|
- window.interfaceConfig,
|
119
|
|
- locationURL);
|
120
|
|
-
|
121
|
|
- let { bosh } = config;
|
122
|
|
-
|
123
|
|
- if (bosh) {
|
124
|
|
- // Normalize the BOSH URL.
|
125
|
|
- if (bosh.startsWith('//')) {
|
126
|
|
- // By default our config.js doesn't include the protocol.
|
127
|
|
- bosh = `${locationURL?.protocol}${bosh}`;
|
128
|
|
- } else if (bosh.startsWith('/')) {
|
129
|
|
- // Handle relative URLs, which won't work on mobile.
|
130
|
|
- const {
|
131
|
|
- protocol,
|
132
|
|
- host,
|
133
|
|
- contextRoot
|
134
|
|
- } = parseURIString(locationURL?.href);
|
135
|
|
-
|
136
|
|
- bosh = `${protocol}//${host}${contextRoot || '/'}${bosh.substr(1)}`;
|
|
101
|
+export function setConfig(config: IConfig = {}) {
|
|
102
|
+ return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
|
103
|
+ const { locationURL } = getState()['features/base/connection'];
|
|
104
|
+
|
|
105
|
+ // Now that the loading of the config was successful override the values
|
|
106
|
+ // with the parameters passed in the hash part of the location URI.
|
|
107
|
+ // TODO We're still in the middle ground between old Web with config,
|
|
108
|
+ // and interfaceConfig used via global variables and new
|
|
109
|
+ // Web and mobile reading the respective values from the redux store.
|
|
110
|
+ // Only the config will be overridden on React Native, as the other
|
|
111
|
+ // globals will be undefined here. It's intentional - we do not care to
|
|
112
|
+ // override those configs yet.
|
|
113
|
+ locationURL
|
|
114
|
+ && setConfigFromURLParams(
|
|
115
|
+
|
|
116
|
+ // On Web the config also comes from the window.config global,
|
|
117
|
+ // but it is resolved in the loadConfig procedure.
|
|
118
|
+ config,
|
|
119
|
+ window.interfaceConfig,
|
|
120
|
+ locationURL);
|
|
121
|
+
|
|
122
|
+ let { bosh } = config;
|
|
123
|
+
|
|
124
|
+ if (bosh) {
|
|
125
|
+ // Normalize the BOSH URL.
|
|
126
|
+ if (bosh.startsWith('//')) {
|
|
127
|
+ // By default our config.js doesn't include the protocol.
|
|
128
|
+ bosh = `${locationURL?.protocol}${bosh}`;
|
|
129
|
+ } else if (bosh.startsWith('/')) {
|
|
130
|
+ // Handle relative URLs, which won't work on mobile.
|
|
131
|
+ const {
|
|
132
|
+ protocol,
|
|
133
|
+ host,
|
|
134
|
+ contextRoot
|
|
135
|
+ } = parseURIString(locationURL?.href);
|
|
136
|
+
|
|
137
|
+ bosh = `${protocol}//${host}${contextRoot || '/'}${bosh.substr(1)}`;
|
|
138
|
+ }
|
|
139
|
+ config.bosh = bosh;
|
137
|
140
|
}
|
138
|
|
- config.bosh = bosh;
|
139
|
|
- }
|
140
|
141
|
|
141
|
|
- return {
|
142
|
|
- type: SET_CONFIG,
|
143
|
|
- config
|
|
142
|
+ dispatch({
|
|
143
|
+ type: SET_CONFIG,
|
|
144
|
+ config
|
|
145
|
+ });
|
144
|
146
|
};
|
145
|
147
|
}
|
146
|
148
|
|