Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

ref(external API): emit CONFERENCE_FAILED on CONNECTION_FAILED

paweldomas82f5eb894b49
diff --git a/react/features/mobile/external-api/middleware.js b/react/features/mobile/external-api/middleware.js
index 3434ae8098..b7ef489a11 100644
--- a/react/features/mobile/external-api/middleware.js
+++ b/react/features/mobile/external-api/middleware.js
@@ -13,6 +13,7 @@ import {
isRoomValid
} from '../../base/conference';
import { LOAD_CONFIG_ERROR } from '../../base/config';
+import { CONNECTION_FAILED } from '../../base/connection';
import { MiddlewareRegistry } from '../../base/redux';
import { toURLString } from '../../base/util';
import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture';
@@ -56,6 +57,10 @@ MiddlewareRegistry.register(store => next => action => {
_sendConferenceEvent(store, action);
break;
+ case CONNECTION_FAILED:
+ _sendConferenceFailedOnConnectionError(store, action);
+ break;
+
case ENTER_PICTURE_IN_PICTURE:
_sendEvent(store, _getSymbolDescription(action.type), /* data */ {});
break;
@@ -175,6 +180,28 @@ function _sendConferenceEvent(
|| _sendEvent(store, _getSymbolDescription(type), data);
}
+/**
+ * Sends {@link CONFERENCE_FAILED} event when the {@link CONNECTION_FAILED}
+ * occurs. Otherwise the external API will not emit such event, because at this
+ * point conference has not been created yet and the base/conference feature
+ * will not emit it.
+ *
+ * @param {Store} store - The redux store.
+ * @param {Action} action - The redux action.
+ * @returns {void}
+ */
+function _sendConferenceFailedOnConnectionError(store, action) {
+ const { locationURL } = store.getState()['features/base/connection'];
+
+ locationURL && _sendEvent(
+ store,
+ _getSymbolDescription(CONFERENCE_FAILED),
+ /* data */ {
+ url: toURLString(locationURL),
+ error: action.error.name
+ });
+}
+
/**
* 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)