2021-06-23 11:23:44 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
|
|
|
|
|
import { approveParticipant } from '../../av-moderation/actions';
|
|
|
|
|
2021-06-24 13:26:55 +00:00
|
|
|
import { QuickActionButton } from './web/styled';
|
2021-06-23 11:23:44 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
|
|
|
* The translated ask unmute text.
|
|
|
|
*/
|
|
|
|
askUnmuteText: string,
|
|
|
|
|
2021-06-23 11:23:44 +00:00
|
|
|
/**
|
2021-08-15 05:27:18 +00:00
|
|
|
* Participant participantID.
|
2021-06-23 11:23:44 +00:00
|
|
|
*/
|
2021-08-15 05:27:18 +00:00
|
|
|
participantID: string,
|
2021-06-23 11:23:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Component used to display the `ask to unmute` button.
|
|
|
|
*
|
|
|
|
* @param {Object} participant - Participant reference.
|
|
|
|
* @returns {React$Element<'button'>}
|
|
|
|
*/
|
2021-08-15 05:27:18 +00:00
|
|
|
export default function AskToUnmuteButton({ askUnmuteText, participantID }: Props) {
|
2021-06-23 11:23:44 +00:00
|
|
|
const dispatch = useDispatch();
|
|
|
|
const askToUnmute = useCallback(() => {
|
2021-08-15 05:27:18 +00:00
|
|
|
dispatch(approveParticipant(participantID));
|
|
|
|
}, [ dispatch, participantID ]);
|
2021-06-23 11:23:44 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<QuickActionButton
|
2021-08-15 05:27:18 +00:00
|
|
|
aria-label = { `unmute-${participantID}` }
|
2021-06-23 11:23:44 +00:00
|
|
|
onClick = { askToUnmute }
|
|
|
|
primary = { true }
|
|
|
|
theme = {{
|
|
|
|
panePadding: 16
|
|
|
|
}}>
|
2021-07-09 12:36:19 +00:00
|
|
|
{ askUnmuteText }
|
2021-06-23 11:23:44 +00:00
|
|
|
</QuickActionButton>
|
|
|
|
);
|
|
|
|
}
|