2022-08-25 11:35:19 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2022-09-13 07:36:00 +00:00
|
|
|
|
|
|
|
import { Theme } from '@mui/material';
|
2021-12-21 12:51:39 +00:00
|
|
|
import React, { useCallback } from 'react';
|
2021-04-21 13:48:05 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2022-02-14 14:47:14 +00:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2022-09-13 07:36:00 +00:00
|
|
|
import { makeStyles } from 'tss-react/mui';
|
2021-04-21 13:48:05 +00:00
|
|
|
|
2022-08-25 11:35:19 +00:00
|
|
|
import { IState } from '../../../app/types';
|
2021-09-28 16:11:13 +00:00
|
|
|
import { rejectParticipantAudio } from '../../../av-moderation/actions';
|
2021-10-22 13:23:52 +00:00
|
|
|
import participantsPaneTheme from '../../../base/components/themes/participantsPaneTheme.json';
|
2021-08-31 08:24:47 +00:00
|
|
|
import { isToolbarButtonEnabled } from '../../../base/config/functions.web';
|
2022-08-25 11:35:19 +00:00
|
|
|
import { MEDIA_TYPE } from '../../../base/media/constants';
|
2022-10-06 11:12:57 +00:00
|
|
|
import { getParticipantById, isScreenShareParticipant } from '../../../base/participants/functions';
|
2022-08-25 11:35:19 +00:00
|
|
|
import { connect } from '../../../base/redux/functions';
|
2022-09-13 07:36:00 +00:00
|
|
|
import { withPixelLineHeight } from '../../../base/styles/functions.web';
|
2022-07-27 08:40:34 +00:00
|
|
|
import Input from '../../../base/ui/components/web/Input';
|
2022-10-06 10:09:40 +00:00
|
|
|
import useContextMenu from '../../../base/ui/hooks/useContextMenu';
|
2022-08-25 11:35:19 +00:00
|
|
|
import { normalizeAccents } from '../../../base/util/strings.web';
|
2022-02-14 14:47:14 +00:00
|
|
|
import { getBreakoutRooms, getCurrentRoomId, isInBreakoutRoom } from '../../../breakout-rooms/functions';
|
2022-10-11 10:47:54 +00:00
|
|
|
import { showOverflowDrawer } from '../../../toolbox/functions.web';
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-09-10 11:05:16 +00:00
|
|
|
import { muteRemote } from '../../../video-menu/actions.any';
|
2021-09-14 15:31:30 +00:00
|
|
|
import { getSortedParticipantIds, shouldRenderInviteButton } from '../../functions';
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-09-10 11:05:16 +00:00
|
|
|
import { useParticipantDrawer } from '../../hooks';
|
2021-04-21 13:48:05 +00:00
|
|
|
|
|
|
|
import { InviteButton } from './InviteButton';
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-07-09 12:36:19 +00:00
|
|
|
import MeetingParticipantContextMenu from './MeetingParticipantContextMenu';
|
2022-08-25 11:35:19 +00:00
|
|
|
// @ts-ignore
|
2021-09-10 11:05:16 +00:00
|
|
|
import MeetingParticipantItems from './MeetingParticipantItems';
|
2021-04-21 13:48:05 +00:00
|
|
|
|
2022-09-13 07:36:00 +00:00
|
|
|
const useStyles = makeStyles()((theme: Theme) => {
|
2021-10-22 13:23:52 +00:00
|
|
|
return {
|
|
|
|
heading: {
|
|
|
|
color: theme.palette.text02,
|
2022-09-13 07:36:00 +00:00
|
|
|
// @ts-ignore
|
|
|
|
...withPixelLineHeight(theme.typography.labelButton),
|
2021-10-22 13:23:52 +00:00
|
|
|
margin: `8px 0 ${participantsPaneTheme.panePadding}px`,
|
|
|
|
|
|
|
|
[`@media(max-width: ${participantsPaneTheme.MD_BREAKPOINT})`]: {
|
2022-09-13 07:36:00 +00:00
|
|
|
// @ts-ignore
|
|
|
|
...withPixelLineHeight(theme.typography.labelButtonLarge)
|
2021-10-22 13:23:52 +00:00
|
|
|
}
|
2022-07-26 10:58:28 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
search: {
|
|
|
|
'& input': {
|
|
|
|
textAlign: 'center',
|
|
|
|
paddingRight: '16px'
|
|
|
|
}
|
2021-10-22 13:23:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
type Props = {
|
2022-09-08 09:52:36 +00:00
|
|
|
currentRoom?: { name: string; };
|
|
|
|
overflowDrawer?: boolean;
|
|
|
|
participantsCount?: number;
|
|
|
|
searchString: string;
|
|
|
|
setSearchString: (newValue: string) => void;
|
|
|
|
showInviteButton?: boolean;
|
|
|
|
sortedParticipantIds?: Array<string>;
|
2021-11-04 21:10:43 +00:00
|
|
|
};
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
|
|
|
* Renders the MeetingParticipantList component.
|
2021-08-24 18:50:13 +00:00
|
|
|
* NOTE: This component is not using useSelector on purpose. The child components MeetingParticipantItem
|
|
|
|
* and MeetingParticipantContextMenu are using connect. Having those mixed leads to problems.
|
|
|
|
* When this one was using useSelector and the other two were not -the other two were re-rendered before this one was
|
|
|
|
* re-rendered, so when participant is leaving, we first re-render the item and menu components,
|
|
|
|
* throwing errors (closing the page) before removing those components for the participant that left.
|
2021-07-09 12:36:19 +00:00
|
|
|
*
|
|
|
|
* @returns {ReactNode} - The component.
|
|
|
|
*/
|
2021-09-14 15:31:30 +00:00
|
|
|
function MeetingParticipants({
|
|
|
|
currentRoom,
|
|
|
|
overflowDrawer,
|
|
|
|
participantsCount,
|
2021-12-21 12:51:39 +00:00
|
|
|
searchString,
|
|
|
|
setSearchString,
|
2021-09-14 15:31:30 +00:00
|
|
|
showInviteButton,
|
|
|
|
sortedParticipantIds = []
|
|
|
|
}: Props) {
|
2021-06-23 11:23:44 +00:00
|
|
|
const dispatch = useDispatch();
|
2021-04-21 13:48:05 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
const [ lowerMenu, , toggleMenu, menuEnter, menuLeave, raiseContext ] = useContextMenu();
|
2021-04-21 13:48:05 +00:00
|
|
|
|
2021-06-23 11:23:44 +00:00
|
|
|
const muteAudio = useCallback(id => () => {
|
2021-09-10 11:05:16 +00:00
|
|
|
dispatch(muteRemote(id, MEDIA_TYPE.AUDIO));
|
2021-09-28 16:11:13 +00:00
|
|
|
dispatch(rejectParticipantAudio(id));
|
2021-09-10 11:05:16 +00:00
|
|
|
}, [ dispatch ]);
|
|
|
|
const [ drawerParticipant, closeDrawer, openDrawerForParticipant ] = useParticipantDrawer();
|
2021-06-23 11:23:44 +00:00
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
// FIXME:
|
2021-09-14 15:31:30 +00:00
|
|
|
// It seems that useTranslation is not very scalable. Unmount 500 components that have the useTranslation hook is
|
2021-07-09 12:36:19 +00:00
|
|
|
// taking more than 10s. To workaround the issue we need to pass the texts as props. This is temporary and dirty
|
|
|
|
// solution!!!
|
|
|
|
// One potential proper fix would be to use react-window component in order to lower the number of components
|
|
|
|
// mounted.
|
2021-09-14 15:31:30 +00:00
|
|
|
const participantActionEllipsisLabel = t('participantsPane.actions.moreParticipantOptions');
|
2021-07-09 12:36:19 +00:00
|
|
|
const youText = t('chat.you');
|
|
|
|
const askUnmuteText = t('participantsPane.actions.askUnmute');
|
|
|
|
const muteParticipantButtonText = t('dialog.muteParticipantButton');
|
2022-02-14 14:47:14 +00:00
|
|
|
const isBreakoutRoom = useSelector(isInBreakoutRoom);
|
2021-07-09 12:36:19 +00:00
|
|
|
|
2022-09-13 07:36:00 +00:00
|
|
|
const { classes: styles } = useStyles();
|
2021-10-22 13:23:52 +00:00
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
return (
|
2021-09-10 11:05:16 +00:00
|
|
|
<>
|
2021-10-22 13:23:52 +00:00
|
|
|
<div className = { styles.heading }>
|
2021-09-14 15:31:30 +00:00
|
|
|
{currentRoom?.name
|
|
|
|
? `${currentRoom.name} (${participantsCount})`
|
|
|
|
: t('participantsPane.headings.participantsList', { count: participantsCount })}
|
2021-10-22 13:23:52 +00:00
|
|
|
</div>
|
2021-09-10 11:05:16 +00:00
|
|
|
{showInviteButton && <InviteButton />}
|
2022-07-26 10:58:28 +00:00
|
|
|
<Input
|
|
|
|
className = { styles.search }
|
|
|
|
clearable = { true }
|
2021-10-21 11:58:44 +00:00
|
|
|
onChange = { setSearchString }
|
2021-12-28 12:14:16 +00:00
|
|
|
placeholder = { t('participantsPane.search') }
|
|
|
|
value = { searchString } />
|
2021-09-10 11:05:16 +00:00
|
|
|
<div>
|
|
|
|
<MeetingParticipantItems
|
|
|
|
askUnmuteText = { askUnmuteText }
|
2022-02-14 14:47:14 +00:00
|
|
|
isInBreakoutRoom = { isBreakoutRoom }
|
2021-09-10 11:05:16 +00:00
|
|
|
lowerMenu = { lowerMenu }
|
|
|
|
muteAudio = { muteAudio }
|
|
|
|
muteParticipantButtonText = { muteParticipantButtonText }
|
|
|
|
openDrawerForParticipant = { openDrawerForParticipant }
|
|
|
|
overflowDrawer = { overflowDrawer }
|
|
|
|
participantActionEllipsisLabel = { participantActionEllipsisLabel }
|
|
|
|
participantIds = { sortedParticipantIds }
|
|
|
|
participantsCount = { participantsCount }
|
2021-09-14 15:31:30 +00:00
|
|
|
raiseContextId = { raiseContext.entity }
|
2021-10-21 11:58:44 +00:00
|
|
|
searchString = { normalizeAccents(searchString) }
|
2021-09-10 11:05:16 +00:00
|
|
|
toggleMenu = { toggleMenu }
|
|
|
|
youText = { youText } />
|
|
|
|
</div>
|
|
|
|
<MeetingParticipantContextMenu
|
|
|
|
closeDrawer = { closeDrawer }
|
|
|
|
drawerParticipant = { drawerParticipant }
|
|
|
|
muteAudio = { muteAudio }
|
2021-09-14 15:31:30 +00:00
|
|
|
offsetTarget = { raiseContext?.offsetTarget }
|
2021-09-10 11:05:16 +00:00
|
|
|
onEnter = { menuEnter }
|
|
|
|
onLeave = { menuLeave }
|
|
|
|
onSelect = { lowerMenu }
|
|
|
|
overflowDrawer = { overflowDrawer }
|
2021-09-14 15:31:30 +00:00
|
|
|
participantID = { raiseContext?.entity } />
|
2021-09-10 11:05:16 +00:00
|
|
|
</>
|
2021-04-21 13:48:05 +00:00
|
|
|
);
|
2021-07-09 12:36:19 +00:00
|
|
|
}
|
2021-08-24 18:50:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @param {Object} ownProps - The own props of the component.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2022-08-25 11:35:19 +00:00
|
|
|
function _mapStateToProps(state: IState): Object {
|
|
|
|
let sortedParticipantIds: any = getSortedParticipantIds(state);
|
2022-05-02 20:39:43 +00:00
|
|
|
|
|
|
|
// Filter out the virtual screenshare participants since we do not want them to be displayed as separate
|
|
|
|
// participants in the participants pane.
|
2022-08-25 11:35:19 +00:00
|
|
|
sortedParticipantIds = sortedParticipantIds.filter((id: any) => {
|
2022-05-02 20:39:43 +00:00
|
|
|
const participant = getParticipantById(state, id);
|
|
|
|
|
2022-10-06 11:12:57 +00:00
|
|
|
return !isScreenShareParticipant(participant);
|
2022-05-02 20:39:43 +00:00
|
|
|
});
|
2021-08-24 18:50:13 +00:00
|
|
|
|
2022-08-01 15:31:38 +00:00
|
|
|
const participantsCount = sortedParticipantIds.length;
|
2021-08-31 08:24:47 +00:00
|
|
|
const showInviteButton = shouldRenderInviteButton(state) && isToolbarButtonEnabled('invite', state);
|
2021-09-10 11:05:16 +00:00
|
|
|
const overflowDrawer = showOverflowDrawer(state);
|
2021-09-14 15:31:30 +00:00
|
|
|
const currentRoomId = getCurrentRoomId(state);
|
|
|
|
const currentRoom = getBreakoutRooms(state)[currentRoomId];
|
|
|
|
|
2021-08-24 18:50:13 +00:00
|
|
|
return {
|
2021-09-14 15:31:30 +00:00
|
|
|
currentRoom,
|
|
|
|
overflowDrawer,
|
2021-08-24 18:50:13 +00:00
|
|
|
participantsCount,
|
2021-09-10 11:05:16 +00:00
|
|
|
showInviteButton,
|
2021-09-14 15:31:30 +00:00
|
|
|
sortedParticipantIds
|
2021-08-24 18:50:13 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-10 11:05:16 +00:00
|
|
|
export default connect(_mapStateToProps)(MeetingParticipants);
|