2021-05-26 07:15:37 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-05-26 11:08:00 +00:00
|
|
|
import React, { useCallback } from 'react';
|
2021-05-26 07:15:37 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { Text, View } from 'react-native';
|
|
|
|
import { Button } from 'react-native-paper';
|
2021-06-29 14:05:11 +00:00
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
2021-05-26 07:15:37 +00:00
|
|
|
|
2021-08-04 08:51:05 +00:00
|
|
|
|
2021-05-26 07:15:37 +00:00
|
|
|
import { Icon, IconInviteMore } from '../../../base/icons';
|
2021-07-12 15:14:38 +00:00
|
|
|
import {
|
|
|
|
getLocalParticipant,
|
|
|
|
getParticipantCountWithFake,
|
2021-08-18 11:29:41 +00:00
|
|
|
getSortedParticipants
|
2021-07-12 15:14:38 +00:00
|
|
|
} from '../../../base/participants';
|
2021-08-04 08:51:05 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2021-05-26 11:08:00 +00:00
|
|
|
import { doInvitePeople } from '../../../invite/actions.native';
|
2021-08-04 08:51:05 +00:00
|
|
|
import {
|
|
|
|
showConnectionStatus,
|
|
|
|
showContextMenuDetails,
|
|
|
|
showSharedVideoMenu
|
|
|
|
} from '../../actions.native';
|
2021-06-09 15:35:58 +00:00
|
|
|
import { shouldRenderInviteButton } from '../../functions';
|
2021-05-26 07:15:37 +00:00
|
|
|
|
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-08-04 08:51:05 +00:00
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shared video local participant owner.
|
|
|
|
*/
|
|
|
|
_localVideoOwner: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
const MeetingParticipantList = ({ _localVideoOwner }: Props) => {
|
2021-05-26 11:08:00 +00:00
|
|
|
const dispatch = useDispatch();
|
2021-06-09 15:35:58 +00:00
|
|
|
const onInvite = useCallback(() => dispatch(doInvitePeople()), [ dispatch ]);
|
2021-07-12 15:14:38 +00:00
|
|
|
const participantsCount = useSelector(getParticipantCountWithFake);
|
2021-08-18 11:29:41 +00:00
|
|
|
const sortedParticipants = useSelector(getSortedParticipants);
|
2021-06-09 15:35:58 +00:00
|
|
|
const showInviteButton = useSelector(shouldRenderInviteButton);
|
2021-05-26 07:15:37 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
2021-07-12 15:14:38 +00:00
|
|
|
// eslint-disable-next-line react/no-multi-comp
|
2021-08-04 08:51:05 +00:00
|
|
|
const renderParticipant = p => {
|
|
|
|
if (p.isFakeParticipant) {
|
|
|
|
if (_localVideoOwner) {
|
|
|
|
return (
|
|
|
|
<MeetingParticipantItem
|
|
|
|
key = { p.id }
|
|
|
|
/* eslint-disable-next-line react/jsx-no-bind,no-confusing-arrow */
|
|
|
|
onPress = { () => dispatch(showSharedVideoMenu(p)) }
|
|
|
|
participantID = { p.id } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<MeetingParticipantItem
|
|
|
|
key = { p.id }
|
|
|
|
participantID = { p.id } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<MeetingParticipantItem
|
|
|
|
key = { p.id }
|
|
|
|
/* eslint-disable-next-line react/jsx-no-bind,no-confusing-arrow */
|
|
|
|
onPress = { () => p.local
|
|
|
|
? dispatch(showConnectionStatus(p.id)) : dispatch(showContextMenuDetails(p)) }
|
|
|
|
participantID = { p.id } />
|
|
|
|
);
|
|
|
|
};
|
2021-07-12 15:14:38 +00:00
|
|
|
|
2021-05-26 07:15:37 +00:00
|
|
|
return (
|
2021-05-26 08:29:21 +00:00
|
|
|
<View style = { styles.meetingList }>
|
|
|
|
<Text style = { styles.meetingListDescription }>
|
2021-05-26 07:15:37 +00:00
|
|
|
{t('participantsPane.headings.participantsList',
|
2021-07-12 15:14:38 +00:00
|
|
|
{ count: participantsCount })}
|
2021-05-26 07:15:37 +00:00
|
|
|
</Text>
|
2021-06-09 15:35:58 +00:00
|
|
|
{
|
|
|
|
showInviteButton
|
|
|
|
&& <Button
|
|
|
|
children = { t('participantsPane.actions.invite') }
|
|
|
|
/* eslint-disable-next-line react/jsx-no-bind */
|
|
|
|
icon = { () =>
|
|
|
|
(<Icon
|
2021-07-06 19:07:52 +00:00
|
|
|
size = { 20 }
|
2021-06-09 15:35:58 +00:00
|
|
|
src = { IconInviteMore } />)
|
|
|
|
}
|
|
|
|
labelStyle = { styles.inviteLabel }
|
|
|
|
mode = 'contained'
|
|
|
|
onPress = { onInvite }
|
|
|
|
style = { styles.inviteButton } />
|
|
|
|
}
|
2021-08-18 11:29:41 +00:00
|
|
|
{ sortedParticipants.map(renderParticipant) }
|
2021-05-26 07:15:37 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
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 {
|
|
|
|
const { ownerId } = state['features/shared-video'];
|
|
|
|
const localParticipantId = getLocalParticipant(state).id;
|
|
|
|
|
|
|
|
return {
|
|
|
|
_localVideoOwner: Boolean(ownerId === localParticipantId)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(_mapStateToProps)(MeetingParticipantList);
|