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
|
|
|
|
|
|
|
import { Icon, IconInviteMore } from '../../../base/icons';
|
2021-07-12 15:14:38 +00:00
|
|
|
import {
|
|
|
|
getLocalParticipant,
|
|
|
|
getParticipantCountWithFake,
|
|
|
|
getRemoteParticipants
|
|
|
|
} from '../../../base/participants';
|
2021-05-26 11:08:00 +00:00
|
|
|
import { doInvitePeople } from '../../../invite/actions.native';
|
2021-07-12 15:14:38 +00:00
|
|
|
import { showContextMenuDetails } 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';
|
|
|
|
|
|
|
|
export const MeetingParticipantList = () => {
|
2021-05-26 11:08:00 +00:00
|
|
|
const dispatch = useDispatch();
|
2021-07-12 15:14:38 +00:00
|
|
|
const items = [];
|
|
|
|
const localParticipant = useSelector(getLocalParticipant);
|
2021-06-09 15:35:58 +00:00
|
|
|
const onInvite = useCallback(() => dispatch(doInvitePeople()), [ dispatch ]);
|
2021-07-12 15:14:38 +00:00
|
|
|
const participants = useSelector(getRemoteParticipants);
|
|
|
|
const participantsCount = useSelector(getParticipantCountWithFake);
|
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-07-27 14:08:33 +00:00
|
|
|
const renderParticipant = p => (
|
|
|
|
|
2021-07-12 15:14:38 +00:00
|
|
|
<MeetingParticipantItem
|
2021-07-27 14:08:33 +00:00
|
|
|
key = { p.id }
|
2021-07-12 15:14:38 +00:00
|
|
|
/* eslint-disable-next-line react/jsx-no-bind */
|
2021-07-27 14:08:33 +00:00
|
|
|
onPress = { () => !p.local && dispatch(showContextMenuDetails(p.id)) }
|
|
|
|
participantID = { p.id } />
|
2021-07-12 15:14:38 +00:00
|
|
|
);
|
|
|
|
|
2021-07-27 14:08:33 +00:00
|
|
|
items.push(renderParticipant(localParticipant));
|
2021-07-12 15:14:38 +00:00
|
|
|
|
|
|
|
participants.forEach(p => {
|
2021-07-27 14:08:33 +00:00
|
|
|
items.push(renderParticipant(p));
|
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-07-12 15:14:38 +00:00
|
|
|
{ items }
|
2021-05-26 07:15:37 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2021-07-12 15:14:38 +00:00
|
|
|
|