feat(notifications) skip join notifications when meetings grow large
This commit is contained in:
parent
c730676ce6
commit
9a8b67a0a4
|
@ -4,6 +4,7 @@ import throttle from 'lodash/throttle';
|
||||||
import type { Dispatch } from 'redux';
|
import type { Dispatch } from 'redux';
|
||||||
|
|
||||||
import { NOTIFICATIONS_ENABLED, getFeatureFlag } from '../base/flags';
|
import { NOTIFICATIONS_ENABLED, getFeatureFlag } from '../base/flags';
|
||||||
|
import { getParticipantCount } from '../base/participants/functions';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CLEAR_NOTIFICATIONS,
|
CLEAR_NOTIFICATIONS,
|
||||||
|
@ -11,7 +12,11 @@ import {
|
||||||
SET_NOTIFICATIONS_ENABLED,
|
SET_NOTIFICATIONS_ENABLED,
|
||||||
SHOW_NOTIFICATION
|
SHOW_NOTIFICATION
|
||||||
} from './actionTypes';
|
} from './actionTypes';
|
||||||
import { NOTIFICATION_TIMEOUT, NOTIFICATION_TYPE } from './constants';
|
import {
|
||||||
|
NOTIFICATION_TIMEOUT,
|
||||||
|
NOTIFICATION_TYPE,
|
||||||
|
SILENT_JOIN_THRESHOLD
|
||||||
|
} from './constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears (removes) all the notifications.
|
* Clears (removes) all the notifications.
|
||||||
|
@ -133,7 +138,16 @@ let joinedParticipantsNames = [];
|
||||||
* @private
|
* @private
|
||||||
* @type {Function}
|
* @type {Function}
|
||||||
*/
|
*/
|
||||||
const _throttledNotifyParticipantConnected = throttle((dispatch: Dispatch<any>) => {
|
const _throttledNotifyParticipantConnected = throttle((dispatch: Dispatch<any>, getState: Function) => {
|
||||||
|
const participantCount = getParticipantCount(getState());
|
||||||
|
|
||||||
|
// Skip join notifications altogether for large meetings.
|
||||||
|
if (participantCount > SILENT_JOIN_THRESHOLD) {
|
||||||
|
joinedParticipantsNames = [];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const joinedParticipantsCount = joinedParticipantsNames.length;
|
const joinedParticipantsCount = joinedParticipantsNames.length;
|
||||||
|
|
||||||
let notificationProps;
|
let notificationProps;
|
||||||
|
@ -182,5 +196,5 @@ const _throttledNotifyParticipantConnected = throttle((dispatch: Dispatch<any>)
|
||||||
export function showParticipantJoinedNotification(displayName: string) {
|
export function showParticipantJoinedNotification(displayName: string) {
|
||||||
joinedParticipantsNames.push(displayName);
|
joinedParticipantsNames.push(displayName);
|
||||||
|
|
||||||
return (dispatch: Dispatch<any>) => _throttledNotifyParticipantConnected(dispatch);
|
return (dispatch: Dispatch<any>, getState: Function) => _throttledNotifyParticipantConnected(dispatch, getState);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,3 +30,8 @@ export const NOTIFICATION_TYPE_PRIORITIES = {
|
||||||
[NOTIFICATION_TYPE.SUCCESS]: 3,
|
[NOTIFICATION_TYPE.SUCCESS]: 3,
|
||||||
[NOTIFICATION_TYPE.WARNING]: 4
|
[NOTIFICATION_TYPE.WARNING]: 4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Amount of participants beyond which no join notification will be emitted.
|
||||||
|
*/
|
||||||
|
export const SILENT_JOIN_THRESHOLD = 30;
|
||||||
|
|
Loading…
Reference in New Issue