2021-05-19 10:08:30 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { Button } from 'react-native-paper';
|
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
|
2021-10-21 09:40:57 +00:00
|
|
|
import { hasRaisedHand } from '../../../base/participants';
|
2021-06-29 14:05:11 +00:00
|
|
|
import { approveKnockingParticipant } from '../../../lobby/actions.native';
|
2021-06-03 16:23:18 +00:00
|
|
|
import { showContextMenuReject } from '../../actions.native';
|
2021-06-29 14:05:11 +00:00
|
|
|
import { MEDIA_STATE } from '../../constants';
|
2021-05-19 10:08:30 +00:00
|
|
|
|
|
|
|
import ParticipantItem from './ParticipantItem';
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Participant reference.
|
2021-05-19 10:08:30 +00:00
|
|
|
*/
|
|
|
|
participant: Object
|
|
|
|
};
|
|
|
|
|
|
|
|
export const LobbyParticipantItem = ({ participant: p }: Props) => {
|
|
|
|
const dispatch = useDispatch();
|
2021-06-29 14:05:11 +00:00
|
|
|
const admit = useCallback(() => dispatch(approveKnockingParticipant(p.id), [ dispatch ]));
|
2021-06-03 16:23:18 +00:00
|
|
|
const openContextMenuReject = useCallback(() => dispatch(showContextMenuReject(p), [ dispatch ]));
|
2021-05-19 10:08:30 +00:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ParticipantItem
|
2021-06-29 14:05:11 +00:00
|
|
|
audioMediaState = { MEDIA_STATE.NONE }
|
2021-07-12 15:14:38 +00:00
|
|
|
displayName = { p.name }
|
2021-06-09 12:41:00 +00:00
|
|
|
isKnockingParticipant = { true }
|
2021-07-12 15:14:38 +00:00
|
|
|
local = { p.local }
|
2021-06-03 16:23:18 +00:00
|
|
|
onPress = { openContextMenuReject }
|
2021-05-19 10:08:30 +00:00
|
|
|
participant = { p }
|
2021-07-12 15:14:38 +00:00
|
|
|
participantID = { p.id }
|
2021-10-21 09:40:57 +00:00
|
|
|
raisedHand = { hasRaisedHand(p) }
|
2021-06-29 14:05:11 +00:00
|
|
|
videoMediaState = { MEDIA_STATE.NONE }>
|
2021-06-03 16:23:18 +00:00
|
|
|
<Button
|
|
|
|
children = { t('lobby.admit') }
|
|
|
|
contentStyle = { styles.participantActionsButtonContent }
|
|
|
|
labelStyle = { styles.participantActionsButtonText }
|
|
|
|
mode = 'contained'
|
|
|
|
onPress = { admit }
|
|
|
|
style = { styles.participantActionsButtonAdmit } />
|
2021-05-19 10:08:30 +00:00
|
|
|
</ParticipantItem>
|
|
|
|
);
|
|
|
|
};
|