Browse Source

feat(notifications) skip join notifications when meetings grow large

master
Saúl Ibarra Corretgé 3 years ago
parent
commit
9a8b67a0a4

+ 17
- 3
react/features/notifications/actions.js View File

4
 import type { Dispatch } from 'redux';
4
 import type { Dispatch } from 'redux';
5
 
5
 
6
 import { NOTIFICATIONS_ENABLED, getFeatureFlag } from '../base/flags';
6
 import { NOTIFICATIONS_ENABLED, getFeatureFlag } from '../base/flags';
7
+import { getParticipantCount } from '../base/participants/functions';
7
 
8
 
8
 import {
9
 import {
9
     CLEAR_NOTIFICATIONS,
10
     CLEAR_NOTIFICATIONS,
11
     SET_NOTIFICATIONS_ENABLED,
12
     SET_NOTIFICATIONS_ENABLED,
12
     SHOW_NOTIFICATION
13
     SHOW_NOTIFICATION
13
 } from './actionTypes';
14
 } from './actionTypes';
14
-import { NOTIFICATION_TIMEOUT, NOTIFICATION_TYPE } from './constants';
15
+import {
16
+    NOTIFICATION_TIMEOUT,
17
+    NOTIFICATION_TYPE,
18
+    SILENT_JOIN_THRESHOLD
19
+} from './constants';
15
 
20
 
16
 /**
21
 /**
17
  * Clears (removes) all the notifications.
22
  * Clears (removes) all the notifications.
133
  * @private
138
  * @private
134
  * @type {Function}
139
  * @type {Function}
135
  */
140
  */
136
-const _throttledNotifyParticipantConnected = throttle((dispatch: Dispatch<any>) => {
141
+const _throttledNotifyParticipantConnected = throttle((dispatch: Dispatch<any>, getState: Function) => {
142
+    const participantCount = getParticipantCount(getState());
143
+
144
+    // Skip join notifications altogether for large meetings.
145
+    if (participantCount > SILENT_JOIN_THRESHOLD) {
146
+        joinedParticipantsNames = [];
147
+
148
+        return;
149
+    }
150
+
137
     const joinedParticipantsCount = joinedParticipantsNames.length;
151
     const joinedParticipantsCount = joinedParticipantsNames.length;
138
 
152
 
139
     let notificationProps;
153
     let notificationProps;
182
 export function showParticipantJoinedNotification(displayName: string) {
196
 export function showParticipantJoinedNotification(displayName: string) {
183
     joinedParticipantsNames.push(displayName);
197
     joinedParticipantsNames.push(displayName);
184
 
198
 
185
-    return (dispatch: Dispatch<any>) => _throttledNotifyParticipantConnected(dispatch);
199
+    return (dispatch: Dispatch<any>, getState: Function) => _throttledNotifyParticipantConnected(dispatch, getState);
186
 }
200
 }

+ 5
- 0
react/features/notifications/constants.js View File

30
     [NOTIFICATION_TYPE.SUCCESS]: 3,
30
     [NOTIFICATION_TYPE.SUCCESS]: 3,
31
     [NOTIFICATION_TYPE.WARNING]: 4
31
     [NOTIFICATION_TYPE.WARNING]: 4
32
 };
32
 };
33
+
34
+/**
35
+ * Amount of participants beyond which no join notification will be emitted.
36
+ */
37
+export const SILENT_JOIN_THRESHOLD = 30;

Loading…
Cancel
Save