2023-01-12 13:47:44 +00:00
|
|
|
/* eslint-disable lines-around-comment */
|
2021-05-26 07:15:37 +00:00
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2023-01-12 13:47:44 +00:00
|
|
|
import { WithTranslation } from 'react-i18next';
|
2022-01-12 16:29:58 +00:00
|
|
|
import { FlatList } from 'react-native';
|
2022-07-07 12:29:18 +00:00
|
|
|
|
2023-01-12 13:47:44 +00:00
|
|
|
import { IReduxState } from '../../../app/types';
|
|
|
|
import { translate } from '../../../base/i18n/functions';
|
|
|
|
// @ts-ignore
|
2022-11-08 10:24:32 +00:00
|
|
|
import { Icon, IconAddUser } from '../../../base/icons';
|
2023-01-12 13:47:44 +00:00
|
|
|
import {
|
|
|
|
getLocalParticipant,
|
|
|
|
getParticipantCountWithFake,
|
|
|
|
getRemoteParticipants
|
|
|
|
} from '../../../base/participants/functions';
|
|
|
|
import { connect } from '../../../base/redux/functions';
|
2022-07-27 08:40:34 +00:00
|
|
|
import Button from '../../../base/ui/components/native/Button';
|
|
|
|
import Input from '../../../base/ui/components/native/Input';
|
2022-11-09 12:45:55 +00:00
|
|
|
import { BUTTON_TYPES } from '../../../base/ui/constants.native';
|
2021-09-14 15:31:30 +00:00
|
|
|
import { getBreakoutRooms, getCurrentRoomId } from '../../../breakout-rooms/functions';
|
2021-05-26 11:08:00 +00:00
|
|
|
import { doInvitePeople } from '../../../invite/actions.native';
|
2023-01-12 13:47:44 +00:00
|
|
|
import { toggleShareDialog } from '../../../share-room/actions';
|
|
|
|
import { getInviteOthersControl } from '../../../share-room/functions';
|
2021-12-21 12:51:39 +00:00
|
|
|
import { participantMatchesSearch, shouldRenderInviteButton } from '../../functions';
|
2021-05-26 07:15:37 +00:00
|
|
|
|
2023-01-12 13:47:44 +00:00
|
|
|
// @ts-ignore
|
2022-01-12 16:29:58 +00:00
|
|
|
import CollapsibleList from './CollapsibleList';
|
2023-01-12 13:47:44 +00:00
|
|
|
// @ts-ignore
|
2021-07-12 15:14:38 +00:00
|
|
|
import MeetingParticipantItem from './MeetingParticipantItem';
|
2023-01-12 13:47:44 +00:00
|
|
|
// @ts-ignore
|
2021-05-26 07:15:37 +00:00
|
|
|
import styles from './styles';
|
|
|
|
|
2021-10-21 11:58:44 +00:00
|
|
|
|
2023-01-12 13:47:44 +00:00
|
|
|
type Props = WithTranslation & {
|
2021-08-04 08:51:05 +00:00
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
/**
|
|
|
|
* Current breakout room, if we are in one.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
_currentRoom: any;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Control for invite other button.
|
|
|
|
*/
|
|
|
|
_inviteOthersControl: any;
|
2021-09-14 15:31:30 +00:00
|
|
|
|
2021-08-04 08:51:05 +00:00
|
|
|
/**
|
2021-10-21 11:58:44 +00:00
|
|
|
* The local participant.
|
2021-09-01 23:13:16 +00:00
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
_localParticipant: any;
|
2021-09-01 23:13:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of participants in the conference.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
_participantsCount: number;
|
2021-09-01 23:13:16 +00:00
|
|
|
|
2021-10-21 11:58:44 +00:00
|
|
|
/**
|
|
|
|
* The remote participants.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
_remoteParticipants: Map<string, Object>;
|
2021-10-21 11:58:44 +00:00
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* Whether or not to show the invite button.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
_showInviteButton: boolean;
|
2021-09-01 23:13:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The remote participants.
|
2021-08-04 08:51:05 +00:00
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
_sortedRemoteParticipants: Map<string, string>;
|
2021-09-01 23:13:16 +00:00
|
|
|
|
2022-03-25 09:09:55 +00:00
|
|
|
/**
|
|
|
|
* List of breakout rooms that were created.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
breakoutRooms: ArrayLike<any>;
|
2022-03-25 09:09:55 +00:00
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* The redux dispatch function.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
dispatch: Function;
|
2021-09-01 23:13:16 +00:00
|
|
|
|
2022-04-12 11:45:27 +00:00
|
|
|
/**
|
|
|
|
* Is the local participant moderator?
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
isLocalModerator: boolean;
|
2022-04-12 11:45:27 +00:00
|
|
|
|
2022-03-25 09:09:55 +00:00
|
|
|
/**
|
|
|
|
* List of participants waiting in lobby.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
lobbyParticipants: ArrayLike<any>;
|
2022-03-25 09:09:55 +00:00
|
|
|
|
2021-12-21 12:51:39 +00:00
|
|
|
/**
|
|
|
|
* Participants search string.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
searchString: string;
|
2021-12-21 12:51:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to update the search string.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
setSearchString: Function;
|
2021-12-21 12:51:39 +00:00
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* Translation function.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
t: Function;
|
|
|
|
};
|
2021-08-04 08:51:05 +00:00
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* The meeting participant list component.
|
|
|
|
*/
|
2021-12-21 12:51:39 +00:00
|
|
|
class MeetingParticipantList extends PureComponent<Props> {
|
2021-09-01 23:13:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates new MeetingParticipantList instance.
|
|
|
|
*
|
|
|
|
* @param {Props} props - The props of the component.
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._keyExtractor = this._keyExtractor.bind(this);
|
|
|
|
this._onInvite = this._onInvite.bind(this);
|
|
|
|
this._renderParticipant = this._renderParticipant.bind(this);
|
2021-10-21 11:58:44 +00:00
|
|
|
this._onSearchStringChange = this._onSearchStringChange.bind(this);
|
2021-09-01 23:13:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a key for a passed item of the list.
|
|
|
|
*
|
|
|
|
* @param {string} item - The user ID.
|
|
|
|
* @returns {string} - The user ID.
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
_keyExtractor(item: string) {
|
2021-09-01 23:13:16 +00:00
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles ivite button presses.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onInvite() {
|
2023-01-12 13:47:44 +00:00
|
|
|
this.props.dispatch(toggleShareDialog(true));
|
2021-09-01 23:13:16 +00:00
|
|
|
this.props.dispatch(doInvitePeople());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a participant.
|
|
|
|
*
|
|
|
|
* @param {Object} flatListItem - Information about the item to be rendered.
|
|
|
|
* @param {string} flatListItem.item - The ID of the participant.
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
_renderParticipant({ item/* , index, separators */ }: any) {
|
2021-12-21 12:51:39 +00:00
|
|
|
const { _localParticipant, _remoteParticipants, searchString } = this.props;
|
2021-10-21 11:58:44 +00:00
|
|
|
const participant = item === _localParticipant?.id ? _localParticipant : _remoteParticipants.get(item);
|
2021-12-21 12:51:39 +00:00
|
|
|
|
|
|
|
if (participantMatchesSearch(participant, searchString)) {
|
2021-10-21 11:58:44 +00:00
|
|
|
return (
|
|
|
|
<MeetingParticipantItem
|
|
|
|
key = { item }
|
|
|
|
participant = { participant } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles search string changes.
|
|
|
|
*
|
|
|
|
* @param {string} text - New value of the search string.
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onSearchStringChange(text: string) {
|
2021-12-21 12:51:39 +00:00
|
|
|
this.props.setSearchString(text);
|
2021-09-01 23:13:16 +00:00
|
|
|
}
|
2021-07-12 15:14:38 +00:00
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const {
|
2021-09-14 15:31:30 +00:00
|
|
|
_currentRoom,
|
2023-01-12 13:47:44 +00:00
|
|
|
_inviteOthersControl,
|
2021-10-21 11:58:44 +00:00
|
|
|
_localParticipant,
|
2021-09-01 23:13:16 +00:00
|
|
|
_participantsCount,
|
|
|
|
_showInviteButton,
|
|
|
|
_sortedRemoteParticipants,
|
2022-03-25 09:09:55 +00:00
|
|
|
breakoutRooms,
|
2022-04-12 11:45:27 +00:00
|
|
|
isLocalModerator,
|
2022-03-25 09:09:55 +00:00
|
|
|
lobbyParticipants,
|
2021-09-01 23:13:16 +00:00
|
|
|
t
|
|
|
|
} = this.props;
|
2022-01-12 16:29:58 +00:00
|
|
|
const title = _currentRoom?.name
|
|
|
|
|
|
|
|
// $FlowExpectedError
|
|
|
|
? `${_currentRoom.name} (${_participantsCount})`
|
|
|
|
: t('participantsPane.headings.participantsList',
|
|
|
|
{ count: _participantsCount });
|
2022-01-12 16:48:12 +00:00
|
|
|
|
|
|
|
// Regarding the fact that we have 3 sections, we apply
|
|
|
|
// a certain height percentage for every section in order for all to fit
|
|
|
|
// inside the participants pane container
|
2022-03-25 09:09:55 +00:00
|
|
|
// If there are only meeting participants available,
|
|
|
|
// we take the full container height
|
|
|
|
const onlyMeetingParticipants
|
2022-04-04 10:25:59 +00:00
|
|
|
= breakoutRooms?.length === 0 && lobbyParticipants?.length === 0;
|
2022-04-12 11:45:27 +00:00
|
|
|
const containerStyleModerator
|
2022-03-25 09:09:55 +00:00
|
|
|
= onlyMeetingParticipants
|
|
|
|
? styles.meetingListFullContainer : styles.meetingListContainer;
|
2022-04-12 11:45:27 +00:00
|
|
|
const containerStyle
|
|
|
|
= isLocalModerator
|
|
|
|
? containerStyleModerator : styles.notLocalModeratorContainer;
|
2022-03-25 09:09:55 +00:00
|
|
|
const finalContainerStyle
|
2022-04-12 11:45:27 +00:00
|
|
|
= _participantsCount > 6 && containerStyle;
|
2023-01-12 13:47:44 +00:00
|
|
|
const { color, shareDialogVisible } = _inviteOthersControl;
|
2021-09-01 23:13:16 +00:00
|
|
|
|
|
|
|
return (
|
2022-01-12 16:29:58 +00:00
|
|
|
<CollapsibleList
|
2022-03-25 09:09:55 +00:00
|
|
|
containerStyle = { finalContainerStyle }
|
2022-01-12 16:29:58 +00:00
|
|
|
title = { title } >
|
2021-09-01 23:13:16 +00:00
|
|
|
{
|
|
|
|
_showInviteButton
|
|
|
|
&& <Button
|
2022-07-07 12:29:18 +00:00
|
|
|
accessibilityLabel = 'participantsPane.actions.invite'
|
2023-01-12 13:47:44 +00:00
|
|
|
disabled = { shareDialogVisible }
|
|
|
|
// eslint-disable-next-line react/jsx-no-bind
|
|
|
|
icon = { () => (
|
|
|
|
<Icon
|
|
|
|
color = { color }
|
|
|
|
size = { 20 }
|
|
|
|
src = { IconAddUser } />
|
|
|
|
) }
|
2022-08-22 09:40:59 +00:00
|
|
|
labelKey = 'participantsPane.actions.invite'
|
|
|
|
onClick = { this._onInvite }
|
2022-07-07 12:29:18 +00:00
|
|
|
style = { styles.inviteButton }
|
|
|
|
type = { BUTTON_TYPES.PRIMARY } />
|
2021-09-01 23:13:16 +00:00
|
|
|
}
|
2022-07-26 10:58:28 +00:00
|
|
|
<Input
|
|
|
|
clearable = { true }
|
2023-01-12 13:47:44 +00:00
|
|
|
// @ts-ignore
|
2022-08-17 10:43:38 +00:00
|
|
|
customStyles = {{
|
|
|
|
container: styles.inputContainer,
|
2022-07-26 10:58:28 +00:00
|
|
|
input: styles.centerInput }}
|
2021-10-21 11:58:44 +00:00
|
|
|
onChange = { this._onSearchStringChange }
|
|
|
|
placeholder = { t('participantsPane.search') }
|
2022-07-26 10:58:28 +00:00
|
|
|
value = { this.props.searchString } />
|
2021-09-01 23:13:16 +00:00
|
|
|
<FlatList
|
|
|
|
bounces = { false }
|
2021-10-21 11:58:44 +00:00
|
|
|
data = { [ _localParticipant?.id, ..._sortedRemoteParticipants ] }
|
2021-09-01 23:13:16 +00:00
|
|
|
horizontal = { false }
|
|
|
|
keyExtractor = { this._keyExtractor }
|
|
|
|
renderItem = { this._renderParticipant }
|
2022-01-12 16:29:58 +00:00
|
|
|
scrollEnabled = { true }
|
2021-09-01 23:13:16 +00:00
|
|
|
showsHorizontalScrollIndicator = { false }
|
|
|
|
windowSize = { 2 } />
|
2022-01-12 16:29:58 +00:00
|
|
|
</CollapsibleList>
|
2021-09-01 23:13:16 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2021-07-12 15:14:38 +00:00
|
|
|
|
2021-08-04 08:51:05 +00:00
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
2023-01-12 13:47:44 +00:00
|
|
|
function _mapStateToProps(state: IReduxState): Object {
|
2021-09-01 23:13:16 +00:00
|
|
|
const _participantsCount = getParticipantCountWithFake(state);
|
|
|
|
const { remoteParticipants } = state['features/filmstrip'];
|
2023-01-12 13:47:44 +00:00
|
|
|
const { shareDialogVisible } = state['features/share-room'];
|
|
|
|
const _inviteOthersControl = getInviteOthersControl(state);
|
2021-09-01 23:13:16 +00:00
|
|
|
const _showInviteButton = shouldRenderInviteButton(state);
|
2021-10-21 11:58:44 +00:00
|
|
|
const _remoteParticipants = getRemoteParticipants(state);
|
2021-09-14 15:31:30 +00:00
|
|
|
const currentRoomId = getCurrentRoomId(state);
|
|
|
|
const _currentRoom = getBreakoutRooms(state)[currentRoomId];
|
2021-08-04 08:51:05 +00:00
|
|
|
|
|
|
|
return {
|
2021-09-14 15:31:30 +00:00
|
|
|
_currentRoom,
|
2023-01-12 13:47:44 +00:00
|
|
|
_inviteOthersControl,
|
2021-09-01 23:13:16 +00:00
|
|
|
_participantsCount,
|
2021-10-21 11:58:44 +00:00
|
|
|
_remoteParticipants,
|
2021-09-01 23:13:16 +00:00
|
|
|
_showInviteButton,
|
|
|
|
_sortedRemoteParticipants: remoteParticipants,
|
2023-01-12 13:47:44 +00:00
|
|
|
_localParticipant: getLocalParticipant(state),
|
|
|
|
_shareDialogVisible: shareDialogVisible
|
2021-08-04 08:51:05 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-07-07 12:29:18 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(MeetingParticipantList));
|