Selaa lähdekoodia

fix(external_api) drop legacy constructor arguments

The new format (using an options object) was introduced 7 years ago.
It's about time.
factor2
Saúl Ibarra Corretgé 6 kuukautta sitten
vanhempi
commit
37856e0fdb
1 muutettua tiedostoa jossa 10 lisäystä ja 82 poistoa
  1. 10
    82
      modules/API/external/external_api.js

+ 10
- 82
modules/API/external/external_api.js Näytä tiedosto

@@ -194,80 +194,6 @@ function changeParticipantNumber(APIInstance, number) {
194 194
     APIInstance._numberOfParticipants += number;
195 195
 }
196 196
 
197
-/**
198
- * Generates the URL for the iframe.
199
- *
200
- * @param {string} domain - The domain name of the server that hosts the
201
- * conference.
202
- * @param {string} [options] - Another optional parameters.
203
- * @param {Object} [options.configOverwrite] - Object containing configuration
204
- * options defined in config.js to be overridden.
205
- * @param {Object} [options.interfaceConfigOverwrite] - Object containing
206
- * configuration options defined in interface_config.js to be overridden.
207
- * @param {string} [options.jwt] - The JWT token if needed by jitsi-meet for
208
- * authentication.
209
- * @param {string} [options.lang] - The meeting's default language.
210
- * @param {string} [options.roomName] - The name of the room to join.
211
- * @returns {string} The URL.
212
- */
213
-function generateURL(domain, options = {}) {
214
-    return urlObjectToString({
215
-        ...options,
216
-        url: `https://${domain}/#jitsi_meet_external_api_id=${id}`
217
-    });
218
-}
219
-
220
-/**
221
- * Parses the arguments passed to the constructor. If the old format is used
222
- * the function translates the arguments to the new format.
223
- *
224
- * @param {Array} args - The arguments to be parsed.
225
- * @returns {Object} JS object with properties.
226
- */
227
-function parseArguments(args) {
228
-    if (!args.length) {
229
-        return {};
230
-    }
231
-
232
-    const firstArg = args[0];
233
-
234
-    switch (typeof firstArg) {
235
-    case 'string': // old arguments format
236
-    case 'undefined': {
237
-        // Not sure which format but we are trying to parse the old
238
-        // format because if the new format is used everything will be undefined
239
-        // anyway.
240
-        const [
241
-            roomName,
242
-            width,
243
-            height,
244
-            parentNode,
245
-            configOverwrite,
246
-            interfaceConfigOverwrite,
247
-            jwt,
248
-            onload,
249
-            lang
250
-        ] = args;
251
-
252
-        return {
253
-            roomName,
254
-            width,
255
-            height,
256
-            parentNode,
257
-            configOverwrite,
258
-            interfaceConfigOverwrite,
259
-            jwt,
260
-            onload,
261
-            lang
262
-        };
263
-    }
264
-    case 'object': // new arguments format
265
-        return args[0];
266
-    default:
267
-        throw new Error('Can\'t parse the arguments!');
268
-    }
269
-}
270
-
271 197
 /**
272 198
  * Compute valid values for height and width. If a number is specified it's
273 199
  * treated as pixel units. If the value is expressed in px, em, pt or
@@ -336,7 +262,7 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
336 262
      * @param {string}  [options.release] - The key used for specifying release if enabled on the backend.
337 263
      * @param {string} [options.sandbox] - Sandbox directive for the created iframe, if desired.
338 264
      */
339
-    constructor(domain, ...args) {
265
+    constructor(domain, options = {}) {
340 266
         super();
341 267
         const {
342 268
             roomName = '',
@@ -345,21 +271,22 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
345 271
             parentNode = document.body,
346 272
             configOverwrite = {},
347 273
             interfaceConfigOverwrite = {},
348
-            jwt = undefined,
349
-            lang = undefined,
350
-            onload = undefined,
274
+            jwt,
275
+            lang,
276
+            onload,
351 277
             invitees,
352 278
             iceServers,
353 279
             devices,
354 280
             userInfo,
355 281
             e2eeKey,
356 282
             release,
357
-            sandbox = ''
358
-        } = parseArguments(args);
283
+            sandbox
284
+        } = options;
359 285
         const localStorageContent = jitsiLocalStorage.getItem('jitsiLocalStorage');
360 286
 
361 287
         this._parentNode = parentNode;
362
-        this._url = generateURL(domain, {
288
+
289
+        this._url = urlObjectToString({
363 290
             configOverwrite,
364 291
             iceServers,
365 292
             interfaceConfigOverwrite,
@@ -371,7 +298,8 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
371 298
             appData: {
372 299
                 localStorageContent
373 300
             },
374
-            release
301
+            release,
302
+            url: `https://${domain}/#jitsi_meet_external_api_id=${id}`
375 303
         });
376 304
 
377 305
         this._createIFrame(height, width, sandbox);

Loading…
Peruuta
Tallenna