You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MeetingParticipantList.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // @flow
  2. import React, { useCallback } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { Text, View } from 'react-native';
  5. import { Button } from 'react-native-paper';
  6. import { useDispatch, useSelector } from 'react-redux';
  7. import { Icon, IconInviteMore } from '../../../base/icons';
  8. import {
  9. getLocalParticipant,
  10. getParticipantCountWithFake,
  11. getRemoteParticipants
  12. } from '../../../base/participants';
  13. import { doInvitePeople } from '../../../invite/actions.native';
  14. import { showConnectionStatus, showContextMenuDetails } from '../../actions.native';
  15. import { shouldRenderInviteButton } from '../../functions';
  16. import MeetingParticipantItem from './MeetingParticipantItem';
  17. import styles from './styles';
  18. export const MeetingParticipantList = () => {
  19. const dispatch = useDispatch();
  20. const items = [];
  21. const localParticipant = useSelector(getLocalParticipant);
  22. const onInvite = useCallback(() => dispatch(doInvitePeople()), [ dispatch ]);
  23. const participants = useSelector(getRemoteParticipants);
  24. const participantsCount = useSelector(getParticipantCountWithFake);
  25. const showInviteButton = useSelector(shouldRenderInviteButton);
  26. const { t } = useTranslation();
  27. // eslint-disable-next-line react/no-multi-comp
  28. const renderParticipant = p => (
  29. <MeetingParticipantItem
  30. key = { p.id }
  31. /* eslint-disable-next-line react/jsx-no-bind,no-confusing-arrow */
  32. onPress = { () => p.local
  33. ? dispatch(showConnectionStatus(p.id)) : dispatch(showContextMenuDetails(p)) }
  34. participantID = { p.id } />
  35. );
  36. items.push(renderParticipant(localParticipant));
  37. participants.forEach(p => {
  38. items.push(renderParticipant(p));
  39. });
  40. return (
  41. <View style = { styles.meetingList }>
  42. <Text style = { styles.meetingListDescription }>
  43. {t('participantsPane.headings.participantsList',
  44. { count: participantsCount })}
  45. </Text>
  46. {
  47. showInviteButton
  48. && <Button
  49. children = { t('participantsPane.actions.invite') }
  50. /* eslint-disable-next-line react/jsx-no-bind */
  51. icon = { () =>
  52. (<Icon
  53. size = { 20 }
  54. src = { IconInviteMore } />)
  55. }
  56. labelStyle = { styles.inviteLabel }
  57. mode = 'contained'
  58. onPress = { onInvite }
  59. style = { styles.inviteButton } />
  60. }
  61. { items }
  62. </View>
  63. );
  64. };