瀏覽代碼

feat(notifications) skip join notifications when meetings grow large

master
Saúl Ibarra Corretgé 3 年之前
父節點
當前提交
9a8b67a0a4
共有 2 個檔案被更改,包括 22 行新增3 行删除
  1. 17
    3
      react/features/notifications/actions.js
  2. 5
    0
      react/features/notifications/constants.js

+ 17
- 3
react/features/notifications/actions.js 查看文件

@@ -4,6 +4,7 @@ import throttle from 'lodash/throttle';
4 4
 import type { Dispatch } from 'redux';
5 5
 
6 6
 import { NOTIFICATIONS_ENABLED, getFeatureFlag } from '../base/flags';
7
+import { getParticipantCount } from '../base/participants/functions';
7 8
 
8 9
 import {
9 10
     CLEAR_NOTIFICATIONS,
@@ -11,7 +12,11 @@ import {
11 12
     SET_NOTIFICATIONS_ENABLED,
12 13
     SHOW_NOTIFICATION
13 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 22
  * Clears (removes) all the notifications.
@@ -133,7 +138,16 @@ let joinedParticipantsNames = [];
133 138
  * @private
134 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 151
     const joinedParticipantsCount = joinedParticipantsNames.length;
138 152
 
139 153
     let notificationProps;
@@ -182,5 +196,5 @@ const _throttledNotifyParticipantConnected = throttle((dispatch: Dispatch<any>)
182 196
 export function showParticipantJoinedNotification(displayName: string) {
183 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 查看文件

@@ -30,3 +30,8 @@ export const NOTIFICATION_TYPE_PRIORITIES = {
30 30
     [NOTIFICATION_TYPE.SUCCESS]: 3,
31 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…
取消
儲存