From 1feff9709c8d4866bd9b0f3031ee7699c278be18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 9 Oct 2019 14:35:09 +0200 Subject: [PATCH] config: drop configLocation and getroomnode options They never worked on mobile and pose an impediment for makinf config.js more future proof. Specially if we want to move to a non-executable form of configuration. --- config.js | 10 --- react/features/base/config/functions.any.js | 65 ------------------- react/features/base/config/getRoomName.js | 18 +---- .../conference/components/web/Conference.js | 28 +------- 4 files changed, 4 insertions(+), 117 deletions(-) diff --git a/config.js b/config.js index d38dfbfa4..cd10908a6 100644 --- a/config.js +++ b/config.js @@ -1,16 +1,6 @@ /* eslint-disable no-unused-vars, no-var */ var config = { - // Configuration - // - - // Alternative location for the configuration. - // configLocation: './config.json', - - // Custom function which given the URL path should return a room name. - // getroomnode: function (path) { return 'someprefixpossiblybasedonpath'; }, - - // Connection // diff --git a/react/features/base/config/functions.any.js b/react/features/base/config/functions.any.js index 9cb964aa1..8f8894d4b 100644 --- a/react/features/base/config/functions.any.js +++ b/react/features/base/config/functions.any.js @@ -8,8 +8,6 @@ import INTERFACE_CONFIG_WHITELIST from './interfaceConfigWhitelist'; import parseURLParams from './parseURLParams'; import logger from './logger'; -declare var $: Object; - // XXX The functions getRoomName and parseURLParams are split out of // functions.js because they are bundled in both app.bundle and // do_external_connect, webpack 1 does not support tree shaking, and we don't @@ -40,69 +38,6 @@ export function createFakeConfig(baseURL: string) { }; } -/** - * Promise wrapper on obtain config method. When HttpConfigFetch will be moved - * to React app it's better to use load config instead. - * - * @param {string} location - URL of the domain from which the config is to be - * obtained. - * @param {string} room - Room name. - * @private - * @returns {Promise} - */ -export function obtainConfig(location: string, room: string): Promise { - return new Promise((resolve, reject) => - _obtainConfig(location, room, (success, error) => { - success ? resolve() : reject(error); - }) - ); -} - -/** - * Sends HTTP POST request to specified {@code endpoint}. In request the name - * of the room is included in JSON format: - * { - * "rooomName": "someroom12345" - * }. - * - * @param {string} endpoint - The name of HTTP endpoint to which to send - * the HTTP POST request. - * @param {string} roomName - The name of the conference room for which config - * is requested. - * @param {Function} complete - The callback to invoke upon success or failure. - * @returns {void} - */ -function _obtainConfig(endpoint: string, roomName: string, complete: Function) { - logger.info(`Send config request to ${endpoint} for room: ${roomName}`); - $.ajax( - endpoint, - { - contentType: 'application/json', - data: JSON.stringify({ roomName }), - dataType: 'json', - method: 'POST', - - error(jqXHR, textStatus, errorThrown) { - logger.error('Get config error: ', jqXHR, errorThrown); - complete(false, `Get config response status: ${textStatus}`); - }, - success(data) { - const { config, interfaceConfig, loggingConfig } = window; - - try { - overrideConfigJSON( - config, interfaceConfig, loggingConfig, - data); - complete(true); - } catch (e) { - logger.error('Parse config error: ', e); - complete(false, e); - } - } - } - ); -} - /* eslint-disable max-params, no-shadow */ /** diff --git a/react/features/base/config/getRoomName.js b/react/features/base/config/getRoomName.js index 87254fd90..b787b6f7d 100644 --- a/react/features/base/config/getRoomName.js +++ b/react/features/base/config/getRoomName.js @@ -1,29 +1,17 @@ -/* @flow */ +// @flow import { getBackendSafeRoomName } from '../util'; -declare var config: Object; - /** * Builds and returns the room name. * * @returns {string} */ export default function getRoomName(): ?string { - const { getroomnode } = config; const path = window.location.pathname; - let roomName; - // Determine the room node from the URL. - if (getroomnode && typeof getroomnode === 'function') { - roomName = getroomnode.call(config, path); - } else { - // Fall back to the default strategy of making assumptions about how the - // URL maps to the room (name). It currently assumes a deployment in - // which the last non-directory component of the path (name) is the - // room. - roomName = path.substring(path.lastIndexOf('/') + 1) || undefined; - } + // The last non-directory component of the path (name) is the room. + const roomName = path.substring(path.lastIndexOf('/') + 1) || undefined; return getBackendSafeRoomName(roomName); } diff --git a/react/features/conference/components/web/Conference.js b/react/features/conference/components/web/Conference.js index b0ecf0f20..93c888ec6 100644 --- a/react/features/conference/components/web/Conference.js +++ b/react/features/conference/components/web/Conference.js @@ -5,7 +5,6 @@ import React from 'react'; import VideoLayout from '../../../../../modules/UI/videolayout/VideoLayout'; -import { obtainConfig } from '../../../base/config'; import { connect, disconnect } from '../../../base/connection'; import { translate } from '../../../base/i18n'; import { connect as reactReduxConnect } from '../../../base/redux'; @@ -23,7 +22,6 @@ import { } from '../../../toolbox'; import { maybeShowSuboptimalExperienceNotification } from '../../functions'; -import logger from '../../logger'; import Labels from './Labels'; import { default as Notice } from './Notice'; @@ -123,31 +121,7 @@ class Conference extends AbstractConference { */ componentDidMount() { document.title = interfaceConfig.APP_NAME; - - const { configLocation } = config; - - if (configLocation) { - obtainConfig(configLocation, this.props._room) - .then(() => { - const now = window.performance.now(); - - APP.connectionTimes['configuration.fetched'] = now; - logger.log('(TIME) configuration fetched:\t', now); - - this._start(); - }) - .catch(err => { - logger.log(err); - - // Show obtain config error. - APP.UI.messageHandler.showError({ - descriptionKey: 'dialog.connectError', - titleKey: 'connection.CONNFAIL' - }); - }); - } else { - this._start(); - } + this._start(); } /**