|
@@ -179,7 +179,7 @@ export function obtainConfig(
|
179
|
179
|
* @returns {void}
|
180
|
180
|
*/
|
181
|
181
|
export function overrideConfigJSON(
|
182
|
|
- config: Object, interfaceConfig: Object, loggingConfig: Object,
|
|
182
|
+ config: ?Object, interfaceConfig: ?Object, loggingConfig: ?Object,
|
183
|
183
|
json: Object) {
|
184
|
184
|
for (const configName of Object.keys(json)) {
|
185
|
185
|
let configObj;
|
|
@@ -212,6 +212,8 @@ export function overrideConfigJSON(
|
212
|
212
|
}
|
213
|
213
|
}
|
214
|
214
|
|
|
215
|
+/* eslint-enable max-params, no-shadow */
|
|
216
|
+
|
215
|
217
|
/**
|
216
|
218
|
* Whitelist only config.js, skips this for others configs
|
217
|
219
|
* (interfaceConfig, loggingConfig).
|
|
@@ -220,9 +222,9 @@ export function overrideConfigJSON(
|
220
|
222
|
* @param {string} configName - The config name, one of config,
|
221
|
223
|
* interfaceConfig, loggingConfig.
|
222
|
224
|
* @param {Object} configJSON - The object with keys and values to override.
|
|
225
|
+ * @private
|
223
|
226
|
* @returns {Object} - The result object only with the keys
|
224
|
227
|
* that are whitelisted.
|
225
|
|
- * @private
|
226
|
228
|
*/
|
227
|
229
|
function _getWhitelistedJSON(configName, configJSON) {
|
228
|
230
|
if (configName !== 'config') {
|
|
@@ -232,40 +234,48 @@ function _getWhitelistedJSON(configName, configJSON) {
|
232
|
234
|
return _.pick(configJSON, WHITELISTED_KEYS);
|
233
|
235
|
}
|
234
|
236
|
|
235
|
|
-/* eslint-enable max-params, no-shadow */
|
|
237
|
+/* eslint-disable max-params */
|
236
|
238
|
|
237
|
239
|
/**
|
238
|
|
- * Converts 'URL_PARAMS' to JSON object.
|
239
|
|
- * We have:
|
240
|
|
- * {
|
241
|
|
- * "config.disableAudioLevels": false,
|
242
|
|
- * "config.channelLastN": -1,
|
243
|
|
- * "interfaceConfig.APP_NAME": "Jitsi Meet"
|
244
|
|
- * }.
|
245
|
|
- * We want to have:
|
246
|
|
- * {
|
247
|
|
- * "config": {
|
248
|
|
- * "disableAudioLevels": false,
|
249
|
|
- * "channelLastN": -1
|
250
|
|
- * },
|
251
|
|
- * interfaceConfig: {
|
252
|
|
- * "APP_NAME": "Jitsi Meet"
|
253
|
|
- * }
|
254
|
|
- * }.
|
|
240
|
+ * Inspects the hash part of the location URI and overrides values specified
|
|
241
|
+ * there in the corresponding config objects given as the arguments. The syntax
|
|
242
|
+ * is: {@code https://server.com/room#config.debug=true
|
|
243
|
+ * &interfaceConfig.showButton=false&loggingConfig.something=1}.
|
255
|
244
|
*
|
|
245
|
+ * In the hash part each parameter will be parsed to JSON and then the root
|
|
246
|
+ * object will be matched with the corresponding config object given as the
|
|
247
|
+ * argument to this function.
|
|
248
|
+ *
|
|
249
|
+ * @param {Object} config - This is the general config.
|
|
250
|
+ * @param {Object} interfaceConfig - This is the interface config.
|
|
251
|
+ * @param {Object} loggingConfig - The logging config.
|
|
252
|
+ * @param {URI} location - The new location to which the app is navigating to.
|
256
|
253
|
* @returns {void}
|
257
|
254
|
*/
|
258
|
|
-export function setConfigFromURLParams() {
|
259
|
|
- const params = parseURLParams(window.location);
|
260
|
|
-
|
261
|
|
- const { config, interfaceConfig, loggingConfig } = window;
|
|
255
|
+export function setConfigFromURLParams(
|
|
256
|
+ config: ?Object,
|
|
257
|
+ interfaceConfig: ?Object,
|
|
258
|
+ loggingConfig: ?Object,
|
|
259
|
+ location: Object) {
|
|
260
|
+ const params = parseURLParams(location);
|
262
|
261
|
const json = {};
|
263
|
262
|
|
264
|
|
- // TODO We're still in the middle ground between old Web with config,
|
265
|
|
- // interfaceConfig, and loggingConfig used via global variables and new Web
|
266
|
|
- // and mobile reading the respective values from the redux store. On React
|
267
|
|
- // Native there's no interfaceConfig at all yet and loggingConfig is not
|
268
|
|
- // loaded but there's a default value in the redux store.
|
|
263
|
+ // At this point we have:
|
|
264
|
+ // params = {
|
|
265
|
+ // "config.disableAudioLevels": false,
|
|
266
|
+ // "config.channelLastN": -1,
|
|
267
|
+ // "interfaceConfig.APP_NAME": "Jitsi Meet"
|
|
268
|
+ // }
|
|
269
|
+ // We want to have:
|
|
270
|
+ // json = {
|
|
271
|
+ // config: {
|
|
272
|
+ // "disableAudioLevels": false,
|
|
273
|
+ // "channelLastN": -1
|
|
274
|
+ // },
|
|
275
|
+ // interfaceConfig: {
|
|
276
|
+ // "APP_NAME": "Jitsi Meet"
|
|
277
|
+ // }
|
|
278
|
+ // }
|
269
|
279
|
config && (json.config = {});
|
270
|
280
|
interfaceConfig && (json.interfaceConfig = {});
|
271
|
281
|
loggingConfig && (json.loggingConfig = {});
|
|
@@ -284,3 +294,5 @@ export function setConfigFromURLParams() {
|
284
|
294
|
|
285
|
295
|
overrideConfigJSON(config, interfaceConfig, loggingConfig, json);
|
286
|
296
|
}
|
|
297
|
+
|
|
298
|
+/* eslint-enable max-params */
|