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.

ParticipantQuickAction.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // @flow
  2. import React from 'react';
  3. import { useTranslation } from 'react-i18next';
  4. import { useSelector } from 'react-redux';
  5. import { QUICK_ACTION_BUTTON } from '../constants';
  6. import { getQuickActionButtonType } from '../functions';
  7. import AskToUnmuteButton from './AskToUnmuteButton';
  8. import { QuickActionButton } from './styled';
  9. type Props = {
  10. /**
  11. * If audio is muted for the current participant.
  12. */
  13. isAudioMuted: Boolean,
  14. /**
  15. * Callback used to open a confirmation dialog for audio muting.
  16. */
  17. muteAudio: Function,
  18. /**
  19. * Participant.
  20. */
  21. participant: Object,
  22. }
  23. /**
  24. * Component used to display mute/ask to unmute button.
  25. *
  26. * @param {Props} props - The props of the component.
  27. * @returns {React$Element<'button'>}
  28. */
  29. export default function({ isAudioMuted, muteAudio, participant }: Props) {
  30. const buttonType = useSelector(getQuickActionButtonType(participant, isAudioMuted));
  31. const { id } = participant;
  32. const { t } = useTranslation();
  33. switch (buttonType) {
  34. case QUICK_ACTION_BUTTON.MUTE: {
  35. return (
  36. <QuickActionButton
  37. onClick = { muteAudio(id) }
  38. primary = { true }>
  39. {t('dialog.muteParticipantButton')}
  40. </QuickActionButton>
  41. );
  42. }
  43. case QUICK_ACTION_BUTTON.ASK_TO_UNMUTE: {
  44. return <AskToUnmuteButton id = { id } />;
  45. }
  46. default: {
  47. return null;
  48. }
  49. }
  50. }