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.

LobbyParticipantItem.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // @flow
  2. import React, { useCallback } from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { Button } from 'react-native-paper';
  5. import { useDispatch } from 'react-redux';
  6. import { hasRaisedHand } from '../../../base/participants';
  7. import { approveKnockingParticipant } from '../../../lobby/actions.native';
  8. import { showContextMenuReject } from '../../actions.native';
  9. import { MEDIA_STATE } from '../../constants';
  10. import ParticipantItem from './ParticipantItem';
  11. import styles from './styles';
  12. type Props = {
  13. /**
  14. * Participant reference
  15. */
  16. participant: Object
  17. };
  18. export const LobbyParticipantItem = ({ participant: p }: Props) => {
  19. const dispatch = useDispatch();
  20. const admit = useCallback(() => dispatch(approveKnockingParticipant(p.id), [ dispatch ]));
  21. const openContextMenuReject = useCallback(() => dispatch(showContextMenuReject(p), [ dispatch ]));
  22. const { t } = useTranslation();
  23. return (
  24. <ParticipantItem
  25. audioMediaState = { MEDIA_STATE.NONE }
  26. displayName = { p.name }
  27. isKnockingParticipant = { true }
  28. local = { p.local }
  29. onPress = { openContextMenuReject }
  30. participant = { p }
  31. participantID = { p.id }
  32. raisedHand = { hasRaisedHand(p) }
  33. videoMediaState = { MEDIA_STATE.NONE }>
  34. <Button
  35. children = { t('lobby.admit') }
  36. contentStyle = { styles.participantActionsButtonContent }
  37. labelStyle = { styles.participantActionsButtonText }
  38. mode = 'contained'
  39. onPress = { admit }
  40. style = { styles.participantActionsButtonAdmit } />
  41. </ParticipantItem>
  42. );
  43. };