Skip to content

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

feat(notifications) trigger iframe api event when a notification occurs (#12952)

Avram Tudor336fa304ce40
diff --git a/modules/API/API.js b/modules/API/API.js
index 83112b7b39..c86df333ec 100644
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -1229,6 +1229,22 @@ class API {
});
}
+ /**
+ * Notify the external app that a notification has been triggered.
+ *
+ * @param {string} title - The notification title.
+ * @param {string} description - The notification description.
+ *
+ * @returns {void}
+ */
+ notifyNotificationTriggered(title: string, description: string) {
+ this._sendEvent({
+ description,
+ name: 'notification-triggered',
+ title
+ });
+ }
+
/**
* Notify external application that the video quality setting has changed.
*
diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js
index d7a3e9e741..3ac76c7a3f 100644
--- a/modules/API/external/external_api.js
+++ b/modules/API/external/external_api.js
@@ -127,6 +127,7 @@ const events = {
'mouse-enter': 'mouseEnter',
'mouse-leave': 'mouseLeave',
'mouse-move': 'mouseMove',
+ 'notification-triggered': 'notificationTriggered',
'outgoing-message': 'outgoingMessage',
'participant-joined': 'participantJoined',
'participant-kicked-out': 'participantKickedOut',
diff --git a/react/features/notifications/actions.ts b/react/features/notifications/actions.ts
index d636093954..7de74dae2b 100644
--- a/react/features/notifications/actions.ts
+++ b/react/features/notifications/actions.ts
@@ -116,12 +116,18 @@ export function showNotification(props: INotificationProps = {}, type?: string)
const { disabledNotifications = [], notifications, notificationTimeouts } = getState()['features/base/config'];
const enabledFlag = getFeatureFlag(getState(), NOTIFICATIONS_ENABLED, true);
+ const { descriptionKey, titleKey } = props;
+
const shouldDisplay = enabledFlag
- && !(disabledNotifications.includes(props.descriptionKey ?? '')
- || disabledNotifications.includes(props.titleKey ?? ''))
+ && !(disabledNotifications.includes(descriptionKey ?? '')
+ || disabledNotifications.includes(titleKey ?? ''))
&& (!notifications
- || notifications.includes(props.descriptionKey ?? '')
- || notifications.includes(props.titleKey ?? ''));
+ || notifications.includes(descriptionKey ?? '')
+ || notifications.includes(titleKey ?? ''));
+
+ if (typeof APP !== 'undefined') {
+ APP.API.notifyNotificationTriggered(titleKey, descriptionKey);
+ }
if (shouldDisplay) {
return dispatch({