diff --git a/react/features/base/util/helpers.js b/react/features/base/util/helpers.js index 8a8e97f39..951d5a0f1 100644 --- a/react/features/base/util/helpers.js +++ b/react/features/base/util/helpers.js @@ -19,6 +19,29 @@ export function getJitsiMeetGlobalNS() { return window.JitsiMeetJS.app; } +/** + * Gets the description of a specific {@code Symbol}. + * + * @param {Symbol} symbol - The {@code Symbol} to retrieve the description of. + * @private + * @returns {string} The description of {@code symbol}. + */ +export function getSymbolDescription(symbol: ?Symbol) { + let description = symbol ? symbol.toString() : 'undefined'; + + if (description.startsWith('Symbol(') && description.endsWith(')')) { + description = description.slice(7, -1); + } + + // The polyfill es6-symbol that we use does not appear to comply with the + // Symbol standard and, merely, adds @@ at the beginning of the description. + if (description.startsWith('@@')) { + description = description.slice(2); + } + + return description; +} + /** * A helper function that behaves similar to Object.assign, but only reassigns a * property in target if it's defined in source. diff --git a/react/features/mobile/external-api/middleware.js b/react/features/mobile/external-api/middleware.js index 9c768a1f4..0acf17e12 100644 --- a/react/features/mobile/external-api/middleware.js +++ b/react/features/mobile/external-api/middleware.js @@ -17,7 +17,7 @@ import { import { LOAD_CONFIG_ERROR } from '../../base/config'; import { CONNECTION_FAILED } from '../../base/connection'; import { MiddlewareRegistry } from '../../base/redux'; -import { toURLString } from '../../base/util'; +import { getSymbolDescription, toURLString } from '../../base/util'; import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture'; /** @@ -66,7 +66,7 @@ MiddlewareRegistry.register(store => next => action => { break; case ENTER_PICTURE_IN_PICTURE: - _sendEvent(store, _getSymbolDescription(type), /* data */ {}); + _sendEvent(store, getSymbolDescription(type), /* data */ {}); break; case LOAD_CONFIG_ERROR: { @@ -74,7 +74,7 @@ MiddlewareRegistry.register(store => next => action => { _sendEvent( store, - _getSymbolDescription(type), + getSymbolDescription(type), /* data */ { error: _toErrorString(error), url: toURLString(locationURL) @@ -110,29 +110,6 @@ function _toErrorString( : ''); } -/** - * Gets the description of a specific {@code Symbol}. - * - * @param {Symbol} symbol - The {@code Symbol} to retrieve the description of. - * @private - * @returns {string} The description of {@code symbol}. - */ -function _getSymbolDescription(symbol: Symbol) { - let description = symbol.toString(); - - if (description.startsWith('Symbol(') && description.endsWith(')')) { - description = description.slice(7, -1); - } - - // The polyfill es6-symbol that we use does not appear to comply with the - // Symbol standard and, merely, adds @@ at the beginning of the description. - if (description.startsWith('@@')) { - description = description.slice(2); - } - - return description; -} - /** * If {@link SET_ROOM} action happens for a valid conference room this method * will emit an early {@link CONFERENCE_WILL_JOIN} event to let the external API @@ -153,7 +130,7 @@ function _maybeTriggerEarlyConferenceWillJoin(store, action) { isRoomValid(room) && locationURL && _sendEvent( store, - _getSymbolDescription(CONFERENCE_WILL_JOIN), + getSymbolDescription(CONFERENCE_WILL_JOIN), /* data */ { url: toURLString(locationURL) }); @@ -184,7 +161,7 @@ function _sendConferenceEvent( } _swallowEvent(store, action, data) - || _sendEvent(store, _getSymbolDescription(type), data); + || _sendEvent(store, getSymbolDescription(type), data); } /** @@ -210,7 +187,7 @@ function _sendConferenceFailedOnConnectionError(store, action) { conference => conference.getConnection() !== connection) && _sendEvent( store, - _getSymbolDescription(CONFERENCE_FAILED), + getSymbolDescription(CONFERENCE_FAILED), /* data */ { url: toURLString(locationURL), error: action.error.name