Просмотр исходного кода

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

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

* remove useless comment

* fix typo
factor2
Avram Tudor 2 лет назад
Родитель
Сommit
336fa304ce
Аккаунт пользователя с таким Email не найден
3 измененных файлов: 27 добавлений и 4 удалений
  1. 16
    0
      modules/API/API.js
  2. 1
    0
      modules/API/external/external_api.js
  3. 10
    4
      react/features/notifications/actions.ts

+ 16
- 0
modules/API/API.js Просмотреть файл

1229
         });
1229
         });
1230
     }
1230
     }
1231
 
1231
 
1232
+    /**
1233
+     * Notify the external app that a notification has been triggered.
1234
+     *
1235
+     * @param {string} title - The notification title.
1236
+     * @param {string} description - The notification description.
1237
+     *
1238
+     * @returns {void}
1239
+     */
1240
+    notifyNotificationTriggered(title: string, description: string) {
1241
+        this._sendEvent({
1242
+            description,
1243
+            name: 'notification-triggered',
1244
+            title
1245
+        });
1246
+    }
1247
+
1232
     /**
1248
     /**
1233
      * Notify external application that the video quality setting has changed.
1249
      * Notify external application that the video quality setting has changed.
1234
      *
1250
      *

+ 1
- 0
modules/API/external/external_api.js Просмотреть файл

127
     'mouse-enter': 'mouseEnter',
127
     'mouse-enter': 'mouseEnter',
128
     'mouse-leave': 'mouseLeave',
128
     'mouse-leave': 'mouseLeave',
129
     'mouse-move': 'mouseMove',
129
     'mouse-move': 'mouseMove',
130
+    'notification-triggered': 'notificationTriggered',
130
     'outgoing-message': 'outgoingMessage',
131
     'outgoing-message': 'outgoingMessage',
131
     'participant-joined': 'participantJoined',
132
     'participant-joined': 'participantJoined',
132
     'participant-kicked-out': 'participantKickedOut',
133
     'participant-kicked-out': 'participantKickedOut',

+ 10
- 4
react/features/notifications/actions.ts Просмотреть файл

116
         const { disabledNotifications = [], notifications, notificationTimeouts } = getState()['features/base/config'];
116
         const { disabledNotifications = [], notifications, notificationTimeouts } = getState()['features/base/config'];
117
         const enabledFlag = getFeatureFlag(getState(), NOTIFICATIONS_ENABLED, true);
117
         const enabledFlag = getFeatureFlag(getState(), NOTIFICATIONS_ENABLED, true);
118
 
118
 
119
+        const { descriptionKey, titleKey } = props;
120
+
119
         const shouldDisplay = enabledFlag
121
         const shouldDisplay = enabledFlag
120
-            && !(disabledNotifications.includes(props.descriptionKey ?? '')
121
-                || disabledNotifications.includes(props.titleKey ?? ''))
122
+            && !(disabledNotifications.includes(descriptionKey ?? '')
123
+                || disabledNotifications.includes(titleKey ?? ''))
122
             && (!notifications
124
             && (!notifications
123
-                || notifications.includes(props.descriptionKey ?? '')
124
-                || notifications.includes(props.titleKey ?? ''));
125
+                || notifications.includes(descriptionKey ?? '')
126
+                || notifications.includes(titleKey ?? ''));
127
+
128
+        if (typeof APP !== 'undefined') {
129
+            APP.API.notifyNotificationTriggered(titleKey, descriptionKey);
130
+        }
125
 
131
 
126
         if (shouldDisplay) {
132
         if (shouldDisplay) {
127
             return dispatch({
133
             return dispatch({

Загрузка…
Отмена
Сохранить