Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(external_api): export sendEvent function
Saúl Ibarra Corretgé39e236a42c84
diff --git a/react/features/mobile/external-api/functions.js b/react/features/mobile/external-api/functions.jsnew file mode 100644index 0000000000..2451cd8dfe--- /dev/null+++ b/react/features/mobile/external-api/functions.js@@ -0,0 +1,26 @@+// @flow++import { NativeModules } from 'react-native';++import { getAppProp } from '../../base/app';++/**+ * Sends a specific event to the native counterpart of the External API. Native+ * apps may listen to such events via the mechanisms provided by the (native)+ * mobile Jitsi Meet SDK.+ *+ * @param {Object} store - The redux store.+ * @param {string} name - The name of the event to send.+ * @param {Object} data - The details/specifics of the event to send determined+ * by/associated with the specified {@code name}.+ * @returns {void}+ */+export function sendEvent(store: Object, name: string, data: Object) {+ // The JavaScript App needs to provide uniquely identifying information to+ // the native ExternalAPI module so that the latter may match the former to+ // the native view which hosts it.+ const externalAPIScope = getAppProp(store, 'externalAPIScope');++ externalAPIScope+ && NativeModules.ExternalAPI.sendEvent(name, data, externalAPIScope);+}diff --git a/react/features/mobile/external-api/index.js b/react/features/mobile/external-api/index.jsindex d436892893..e975ed0e86 100644--- a/react/features/mobile/external-api/index.js+++ b/react/features/mobile/external-api/index.js@@ -1 +1,3 @@+export * from './functions';+import './middleware';diff --git a/react/features/mobile/external-api/middleware.js b/react/features/mobile/external-api/middleware.jsindex 0acf17e12e..e665524e8b 100644--- a/react/features/mobile/external-api/middleware.js+++ b/react/features/mobile/external-api/middleware.js@@ -1,8 +1,5 @@// @flow-import { NativeModules } from 'react-native';--import { getAppProp } from '../../base/app';import {CONFERENCE_FAILED,CONFERENCE_JOINED,@@ -20,6 +17,8 @@ import { MiddlewareRegistry } from '../../base/redux';import { getSymbolDescription, toURLString } from '../../base/util';import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';+import { sendEvent } from './functions';+/*** Middleware that captures Redux actions and uses the ExternalAPI module to* turn them into native events so the application knows about them.@@ -66,13 +65,13 @@ 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: {const { error, locationURL } = action;- _sendEvent(+ sendEvent(store,getSymbolDescription(type),/* data */ {@@ -128,7 +127,7 @@ function _maybeTriggerEarlyConferenceWillJoin(store, action) {const { locationURL } = store.getState()['features/base/connection'];const { room } = action;- isRoomValid(room) && locationURL && _sendEvent(+ isRoomValid(room) && locationURL && sendEvent(store,getSymbolDescription(CONFERENCE_WILL_JOIN),/* data */ {@@ -161,7 +160,7 @@ function _sendConferenceEvent(}_swallowEvent(store, action, data)- || _sendEvent(store, getSymbolDescription(type), data);+ || sendEvent(store, getSymbolDescription(type), data);}/**@@ -185,7 +184,7 @@ function _sendConferenceFailedOnConnectionError(store, action) {// If there's any conference in the base/conference state then the// base/conference feature is supposed to emit a failure.conference => conference.getConnection() !== connection)- && _sendEvent(+ && sendEvent(store,getSymbolDescription(CONFERENCE_FAILED),/* data */ {@@ -194,28 +193,6 @@ function _sendConferenceFailedOnConnectionError(store, action) {});}-/**- * Sends a specific event to the native counterpart of the External API. Native- * apps may listen to such events via the mechanisms provided by the (native)- * mobile Jitsi Meet SDK.- *- * @param {Object} store - The redux store.- * @param {string} name - The name of the event to send.- * @param {Object} data - The details/specifics of the event to send determined- * by/associated with the specified {@code name}.- * @private- * @returns {void}- */-function _sendEvent(store: Object, name: string, data: Object) {- // The JavaScript App needs to provide uniquely identifying information to- // the native ExternalAPI module so that the latter may match the former to- // the native JitsiMeetView which hosts it.- const externalAPIScope = getAppProp(store, 'externalAPIScope');-- externalAPIScope- && NativeModules.ExternalAPI.sendEvent(name, data, externalAPIScope);-}-/*** Determines whether to not send a {@code CONFERENCE_LEFT} event to the native* counterpart of the External API.