mirror of
https://gitcode.com/GitHub_Trending/ji/jitsi-meet.git
synced 2026-05-14 17:17:47 +00:00
* fix(participants): Change from array to Map
* fix(unload): optimise
* feat: Introduces new states for e2ee feature.
Stores everyoneSupportsE2EE and everyoneEnabledE2EE to minimize looping through participants list.
squash: Uses participants map and go over the elements only once.
* feat: Optimizes isEveryoneModerator to do less frequent checks in all participants.
* fix: Drops deep equal from participants pane and uses the map.
* fix(SharedVideo): isVideoPlaying
* fix(participants): Optimise isEveryoneModerator
* fix(e2e): Optimise everyoneEnabledE2EE
* fix: JS errors.
* ref(participants): remove getParticipants
* fix(participants): Prepare for PR.
* fix: Changes participants pane to be component.
The functional component was always rendered:
`prev props: {} !== {} :next props`.
* feat: Optimization to skip participants list on pane closed.
* fix: The participants list shows and the local participant.
* fix: Fix wrong action name for av-moderation.
* fix: Minimizes the number of render calls of av moderation notification.
* fix: Fix iterating over remote participants.
* fix: Fixes lint error.
* fix: Reflects participant updates for av-moderation.
* fix(ParticipantPane): to work with IDs.
* fix(av-moderation): on PARTCIPANT_UPDATE
* fix(ParticipantPane): close delay.
* fix: address code review comments
* fix(API): mute-everyone
* fix: bugs
* fix(Thumbnail): on mobile.
* fix(ParticipantPane): Close context menu on click.
* fix: Handles few error when local participant is undefined.
* feat: Hides AV moderation if not supported.
* fix: Show mute all video.
* fix: Fixes updating participant for av moderation.
Co-authored-by: damencho <damencho@jitsi.org>
235 lines
6.4 KiB
JavaScript
235 lines
6.4 KiB
JavaScript
/* @flow */
|
|
|
|
import { MEDIA_TYPE } from '../base/media/constants';
|
|
import type { MediaType } from '../base/media/constants';
|
|
import {
|
|
PARTICIPANT_LEFT,
|
|
PARTICIPANT_UPDATED
|
|
} from '../base/participants';
|
|
import { ReducerRegistry } from '../base/redux';
|
|
|
|
import {
|
|
DISABLE_MODERATION,
|
|
DISMISS_PENDING_PARTICIPANT,
|
|
ENABLE_MODERATION,
|
|
LOCAL_PARTICIPANT_APPROVED,
|
|
PARTICIPANT_APPROVED,
|
|
PARTICIPANT_PENDING_AUDIO
|
|
} from './actionTypes';
|
|
import { MEDIA_TYPE_TO_PENDING_STORE_KEY } from './constants';
|
|
|
|
const initialState = {
|
|
audioModerationEnabled: false,
|
|
videoModerationEnabled: false,
|
|
audioWhitelist: {},
|
|
videoWhitelist: {},
|
|
pendingAudio: [],
|
|
pendingVideo: []
|
|
};
|
|
|
|
/**
|
|
Updates a participant in the state for the specified media type.
|
|
*
|
|
* @param {MediaType} mediaType - The media type.
|
|
* @param {Object} participant - Information about participant to be modified.
|
|
* @param {Object} state - The current state.
|
|
* @private
|
|
* @returns {boolean} - Whether state instance was modified.
|
|
*/
|
|
function _updatePendingParticipant(mediaType: MediaType, participant, state: Object = {}) {
|
|
let arrayItemChanged = false;
|
|
const storeKey = MEDIA_TYPE_TO_PENDING_STORE_KEY[mediaType];
|
|
const arr = state[storeKey];
|
|
const newArr = arr.map(pending => {
|
|
if (pending.id === participant.id) {
|
|
arrayItemChanged = true;
|
|
|
|
return {
|
|
...pending,
|
|
...participant
|
|
};
|
|
}
|
|
|
|
return pending;
|
|
});
|
|
|
|
if (arrayItemChanged) {
|
|
state[storeKey] = newArr;
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
ReducerRegistry.register('features/av-moderation', (state = initialState, action) => {
|
|
|
|
switch (action.type) {
|
|
case DISABLE_MODERATION: {
|
|
const newState = action.mediaType === MEDIA_TYPE.AUDIO
|
|
? {
|
|
audioModerationEnabled: false,
|
|
audioUnmuteApproved: undefined
|
|
} : {
|
|
videoModerationEnabled: false,
|
|
videoUnmuteApproved: undefined
|
|
};
|
|
|
|
return {
|
|
...state,
|
|
...newState,
|
|
audioWhitelist: {},
|
|
videoWhitelist: {},
|
|
pendingAudio: [],
|
|
pendingVideo: []
|
|
};
|
|
}
|
|
|
|
case ENABLE_MODERATION: {
|
|
const newState = action.mediaType === MEDIA_TYPE.AUDIO
|
|
? { audioModerationEnabled: true } : { videoModerationEnabled: true };
|
|
|
|
return {
|
|
...state,
|
|
...newState
|
|
};
|
|
}
|
|
|
|
case LOCAL_PARTICIPANT_APPROVED: {
|
|
const newState = action.mediaType === MEDIA_TYPE.AUDIO
|
|
? { audioUnmuteApproved: true } : { videoUnmuteApproved: true };
|
|
|
|
return {
|
|
...state,
|
|
...newState
|
|
};
|
|
}
|
|
|
|
case PARTICIPANT_PENDING_AUDIO: {
|
|
const { participant } = action;
|
|
|
|
// Add participant to pendingAudio array only if it's not already added
|
|
if (!state.pendingAudio.find(pending => pending.id === participant.id)) {
|
|
const updated = [ ...state.pendingAudio ];
|
|
|
|
updated.push(participant);
|
|
|
|
return {
|
|
...state,
|
|
pendingAudio: updated
|
|
};
|
|
}
|
|
|
|
return state;
|
|
}
|
|
|
|
case PARTICIPANT_UPDATED: {
|
|
const participant = action.participant;
|
|
const { audioModerationEnabled, videoModerationEnabled } = state;
|
|
let hasStateChanged = false;
|
|
|
|
// skips changing the reference of pendingAudio or pendingVideo,
|
|
// if there is no change in the elements
|
|
if (audioModerationEnabled) {
|
|
hasStateChanged = _updatePendingParticipant(MEDIA_TYPE.AUDIO, participant, state);
|
|
}
|
|
|
|
if (videoModerationEnabled) {
|
|
hasStateChanged = _updatePendingParticipant(MEDIA_TYPE.VIDEO, participant, state);
|
|
}
|
|
|
|
// If the state has changed we need to return a new object reference in order to trigger subscriber updates.
|
|
if (hasStateChanged) {
|
|
return {
|
|
...state
|
|
};
|
|
}
|
|
|
|
return state;
|
|
}
|
|
case PARTICIPANT_LEFT: {
|
|
const participant = action.participant;
|
|
const { audioModerationEnabled, videoModerationEnabled } = state;
|
|
let hasStateChanged = false;
|
|
|
|
// skips changing the reference of pendingAudio or pendingVideo,
|
|
// if there is no change in the elements
|
|
if (audioModerationEnabled) {
|
|
const newPendingAudio = state.pendingAudio.filter(pending => pending.id !== participant.id);
|
|
|
|
if (state.pendingAudio.length !== newPendingAudio.length) {
|
|
state.pendingAudio = newPendingAudio;
|
|
hasStateChanged = true;
|
|
}
|
|
}
|
|
|
|
if (videoModerationEnabled) {
|
|
const newPendingVideo = state.pendingVideo.filter(pending => pending.id !== participant.id);
|
|
|
|
if (state.pendingVideo.length !== newPendingVideo.length) {
|
|
state.pendingVideo = newPendingVideo;
|
|
hasStateChanged = true;
|
|
}
|
|
}
|
|
|
|
// If the state has changed we need to return a new object reference in order to trigger subscriber updates.
|
|
if (hasStateChanged) {
|
|
return {
|
|
...state
|
|
};
|
|
}
|
|
|
|
return state;
|
|
}
|
|
|
|
case DISMISS_PENDING_PARTICIPANT: {
|
|
const { participant, mediaType } = action;
|
|
|
|
if (mediaType === MEDIA_TYPE.AUDIO) {
|
|
return {
|
|
...state,
|
|
pendingAudio: state.pendingAudio.filter(pending => pending.id !== participant.id)
|
|
};
|
|
}
|
|
|
|
if (mediaType === MEDIA_TYPE.VIDEO) {
|
|
return {
|
|
...state,
|
|
pendingVideo: state.pendingVideo.filter(pending => pending.id !== participant.id)
|
|
};
|
|
}
|
|
|
|
return state;
|
|
}
|
|
|
|
case PARTICIPANT_APPROVED: {
|
|
const { mediaType, id } = action;
|
|
|
|
if (mediaType === MEDIA_TYPE.AUDIO) {
|
|
return {
|
|
...state,
|
|
audioWhitelist: {
|
|
...state.audioWhitelist,
|
|
[id]: true
|
|
}
|
|
};
|
|
}
|
|
|
|
if (mediaType === MEDIA_TYPE.VIDEO) {
|
|
return {
|
|
...state,
|
|
videoWhitelist: {
|
|
...state.videoWhitelist,
|
|
[id]: true
|
|
}
|
|
};
|
|
}
|
|
|
|
return state;
|
|
}
|
|
|
|
}
|
|
|
|
return state;
|
|
});
|