2021-05-26 07:15:37 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-01-12 16:29:58 +00:00
|
|
|
import { FlatList } from 'react-native';
|
2022-07-07 12:29:18 +00:00
|
|
|
|
2021-08-04 08:51:05 +00:00
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2021-05-26 07:15:37 +00:00
|
|
|
import { Icon, IconInviteMore } from '../../../base/icons';
|
2021-10-21 11:58:44 +00:00
|
|
|
import { getLocalParticipant, getParticipantCountWithFake, getRemoteParticipants } from '../../../base/participants';
|
2022-07-07 12:29:18 +00:00
|
|
|
import Button from '../../../base/react/components/native/Button';
|
|
|
|
import { BUTTON_TYPES } from '../../../base/react/constants';
|
2021-08-04 08:51:05 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2022-07-07 12:29:18 +00:00
|
|
|
import BaseTheme from '../../../base/ui/components/BaseTheme.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';
|
2021-12-21 12:51:39 +00:00
|
|
|
import { participantMatchesSearch, shouldRenderInviteButton } from '../../functions';
|
2021-05-26 07:15:37 +00:00
|
|
|
|
2021-10-21 11:58:44 +00:00
|
|
|
import ClearableInput from './ClearableInput';
|
2022-01-12 16:29:58 +00:00
|
|
|
import CollapsibleList from './CollapsibleList';
|
2021-07-12 15:14:38 +00:00
|
|
|
import MeetingParticipantItem from './MeetingParticipantItem';
|
2021-05-26 07:15:37 +00:00
|
|
|
import styles from './styles';
|
|
|
|
|
2021-10-21 11:58:44 +00:00
|
|
|
|
2021-08-04 08:51:05 +00:00
|
|
|
type Props = {
|
|
|
|
|
2021-09-14 15:31:30 +00:00
|
|
|
/**
|
|
|
|
* Current breakout room, if we are in one.
|
|
|
|
*/
|
|
|
|
_currentRoom: ?Object,
|
|
|
|
|
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
|
|
|
*/
|
2021-10-21 11:58:44 +00:00
|
|
|
_localParticipant: Object,
|
2021-09-01 23:13:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The number of participants in the conference.
|
|
|
|
*/
|
|
|
|
_participantsCount: number,
|
|
|
|
|
2021-10-21 11:58:44 +00:00
|
|
|
/**
|
|
|
|
* The remote participants.
|
|
|
|
*/
|
|
|
|
_remoteParticipants: Map<string, Object>,
|
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* Whether or not to show the invite button.
|
|
|
|
*/
|
|
|
|
_showInviteButton: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The remote participants.
|
2021-08-04 08:51:05 +00:00
|
|
|
*/
|
2021-09-01 23:13:16 +00:00
|
|
|
_sortedRemoteParticipants: Map<string, string>,
|
|
|
|
|
2022-03-25 09:09:55 +00:00
|
|
|
/**
|
|
|
|
* List of breakout rooms that were created.
|
|
|
|
*/
|
|
|
|
breakoutRooms: Array,
|
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* The redux dispatch function.
|
|
|
|
*/
|
|
|
|
dispatch: Function,
|
|
|
|
|
2022-04-12 11:45:27 +00:00
|
|
|
/**
|
|
|
|
* Is the local participant moderator?
|
|
|
|
*/
|
|
|
|
isLocalModerator: boolean,
|
|
|
|
|
2022-03-25 09:09:55 +00:00
|
|
|
/**
|
|
|
|
* List of participants waiting in lobby.
|
|
|
|
*/
|
|
|
|
lobbyParticipants: Array,
|
|
|
|
|
2021-12-21 12:51:39 +00:00
|
|
|
/**
|
|
|
|
* Participants search string.
|
|
|
|
*/
|
|
|
|
searchString: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to update the search string.
|
|
|
|
*/
|
|
|
|
setSearchString: Function,
|
|
|
|
|
2021-09-01 23:13:16 +00:00
|
|
|
/**
|
|
|
|
* Translation function.
|
|
|
|
*/
|
2022-07-07 12:29:18 +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
|
|
|
}
|
|
|
|
|
|
|
|
_keyExtractor: Function;
|
2021-08-04 08:51:05 +00:00
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
_keyExtractor(item) {
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
_onInvite: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handles ivite button presses.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onInvite() {
|
|
|
|
this.props.dispatch(doInvitePeople());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the "invite more" icon.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderInviteMoreIcon() {
|
|
|
|
return (
|
|
|
|
<Icon
|
|
|
|
size = { 20 }
|
|
|
|
src = { IconInviteMore } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
_renderParticipant: Object => Object;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders a participant.
|
|
|
|
*
|
|
|
|
* @param {Object} flatListItem - Information about the item to be rendered.
|
|
|
|
* @param {string} flatListItem.item - The ID of the participant.
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
_renderParticipant({ item/* , index, separators */ }) {
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
_onSearchStringChange: (text: string) => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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,
|
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;
|
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'
|
2021-09-01 23:13:16 +00:00
|
|
|
icon = { this._renderInviteMoreIcon }
|
2022-07-07 12:29:18 +00:00
|
|
|
label = 'participantsPane.actions.invite'
|
2021-09-01 23:13:16 +00:00
|
|
|
onPress = { 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
|
|
|
}
|
2021-10-21 11:58:44 +00:00
|
|
|
<ClearableInput
|
|
|
|
onChange = { this._onSearchStringChange }
|
|
|
|
placeholder = { t('participantsPane.search') }
|
2022-07-07 12:29:18 +00:00
|
|
|
selectionColor = { BaseTheme.palette.text01 } />
|
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}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state): Object {
|
2021-09-01 23:13:16 +00:00
|
|
|
const _participantsCount = getParticipantCountWithFake(state);
|
|
|
|
const { remoteParticipants } = state['features/filmstrip'];
|
|
|
|
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,
|
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,
|
2021-10-21 11:58:44 +00:00
|
|
|
_localParticipant: getLocalParticipant(state)
|
2021-08-04 08:51:05 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-07-07 12:29:18 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(MeetingParticipantList));
|