mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2025-12-30 03:12:29 +00:00
fix(external_api) drop legacy constructor arguments
The new format (using an options object) was introduced 7 years ago. It's about time.
This commit is contained in:
committed by
Saúl Ibarra Corretgé
parent
7c1de52f6a
commit
37856e0fdb
92
modules/API/external/external_api.js
vendored
92
modules/API/external/external_api.js
vendored
@@ -194,80 +194,6 @@ function changeParticipantNumber(APIInstance, number) {
|
||||
APIInstance._numberOfParticipants += number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the URL for the iframe.
|
||||
*
|
||||
* @param {string} domain - The domain name of the server that hosts the
|
||||
* conference.
|
||||
* @param {string} [options] - Another optional parameters.
|
||||
* @param {Object} [options.configOverwrite] - Object containing configuration
|
||||
* options defined in config.js to be overridden.
|
||||
* @param {Object} [options.interfaceConfigOverwrite] - Object containing
|
||||
* configuration options defined in interface_config.js to be overridden.
|
||||
* @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
|
||||
* authentication.
|
||||
* @param {string} [options.lang] - The meeting's default language.
|
||||
* @param {string} [options.roomName] - The name of the room to join.
|
||||
* @returns {string} The URL.
|
||||
*/
|
||||
function generateURL(domain, options = {}) {
|
||||
return urlObjectToString({
|
||||
...options,
|
||||
url: `https://${domain}/#jitsi_meet_external_api_id=${id}`
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the arguments passed to the constructor. If the old format is used
|
||||
* the function translates the arguments to the new format.
|
||||
*
|
||||
* @param {Array} args - The arguments to be parsed.
|
||||
* @returns {Object} JS object with properties.
|
||||
*/
|
||||
function parseArguments(args) {
|
||||
if (!args.length) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const firstArg = args[0];
|
||||
|
||||
switch (typeof firstArg) {
|
||||
case 'string': // old arguments format
|
||||
case 'undefined': {
|
||||
// Not sure which format but we are trying to parse the old
|
||||
// format because if the new format is used everything will be undefined
|
||||
// anyway.
|
||||
const [
|
||||
roomName,
|
||||
width,
|
||||
height,
|
||||
parentNode,
|
||||
configOverwrite,
|
||||
interfaceConfigOverwrite,
|
||||
jwt,
|
||||
onload,
|
||||
lang
|
||||
] = args;
|
||||
|
||||
return {
|
||||
roomName,
|
||||
width,
|
||||
height,
|
||||
parentNode,
|
||||
configOverwrite,
|
||||
interfaceConfigOverwrite,
|
||||
jwt,
|
||||
onload,
|
||||
lang
|
||||
};
|
||||
}
|
||||
case 'object': // new arguments format
|
||||
return args[0];
|
||||
default:
|
||||
throw new Error('Can\'t parse the arguments!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute valid values for height and width. If a number is specified it's
|
||||
* treated as pixel units. If the value is expressed in px, em, pt or
|
||||
@@ -336,7 +262,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
* @param {string} [options.release] - The key used for specifying release if enabled on the backend.
|
||||
* @param {string} [options.sandbox] - Sandbox directive for the created iframe, if desired.
|
||||
*/
|
||||
constructor(domain, ...args) {
|
||||
constructor(domain, options = {}) {
|
||||
super();
|
||||
const {
|
||||
roomName = '',
|
||||
@@ -345,21 +271,22 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
parentNode = document.body,
|
||||
configOverwrite = {},
|
||||
interfaceConfigOverwrite = {},
|
||||
jwt = undefined,
|
||||
lang = undefined,
|
||||
onload = undefined,
|
||||
jwt,
|
||||
lang,
|
||||
onload,
|
||||
invitees,
|
||||
iceServers,
|
||||
devices,
|
||||
userInfo,
|
||||
e2eeKey,
|
||||
release,
|
||||
sandbox = ''
|
||||
} = parseArguments(args);
|
||||
sandbox
|
||||
} = options;
|
||||
const localStorageContent = jitsiLocalStorage.getItem('jitsiLocalStorage');
|
||||
|
||||
this._parentNode = parentNode;
|
||||
this._url = generateURL(domain, {
|
||||
|
||||
this._url = urlObjectToString({
|
||||
configOverwrite,
|
||||
iceServers,
|
||||
interfaceConfigOverwrite,
|
||||
@@ -371,7 +298,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
||||
appData: {
|
||||
localStorageContent
|
||||
},
|
||||
release
|
||||
release,
|
||||
url: `https://${domain}/#jitsi_meet_external_api_id=${id}`
|
||||
});
|
||||
|
||||
this._createIFrame(height, width, sandbox);
|
||||
|
||||
Reference in New Issue
Block a user