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.

MeetingParticipantItem.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // @flow
  2. import React from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import {
  5. getParticipantByIdOrUndefined,
  6. getParticipantDisplayName
  7. } from '../../../base/participants';
  8. import { connect } from '../../../base/redux';
  9. import {
  10. isParticipantAudioMuted,
  11. isParticipantVideoMuted
  12. } from '../../../base/tracks';
  13. import { MEDIA_STATE } from '../../constants';
  14. import type { MediaState } from '../../constants';
  15. import { getParticipantAudioMediaState } from '../../functions';
  16. import ParticipantItem from './ParticipantItem';
  17. type Props = {
  18. /**
  19. * Media state for audio.
  20. */
  21. _audioMediaState: MediaState,
  22. /**
  23. * The display name of the participant.
  24. */
  25. _displayName: string,
  26. /**
  27. * True if the participant is video muted.
  28. */
  29. _isVideoMuted: boolean,
  30. /**
  31. * True if the participant is the local participant.
  32. */
  33. _local: boolean,
  34. /**
  35. * The participant ID.
  36. */
  37. _participantID: string,
  38. /**
  39. * True if the participant have raised hand.
  40. */
  41. _raisedHand: boolean,
  42. /**
  43. * Callback to invoke when item is pressed.
  44. */
  45. onPress: Function,
  46. /**
  47. * The ID of the participant.
  48. */
  49. participantID: ?string
  50. };
  51. /**
  52. * Implements the MeetingParticipantItem component.
  53. *
  54. * @param {Props} props - The props of the component.
  55. * @returns {ReactElement}
  56. */
  57. function MeetingParticipantItem({
  58. _audioMediaState,
  59. _displayName,
  60. _isVideoMuted,
  61. _local,
  62. _participantID,
  63. _raisedHand,
  64. onPress
  65. }: Props) {
  66. return (
  67. <ParticipantItem
  68. audioMediaState = { _audioMediaState }
  69. displayName = { _displayName }
  70. isKnockingParticipant = { false }
  71. local = { _local }
  72. onPress = { onPress }
  73. participantID = { _participantID }
  74. raisedHand = { _raisedHand }
  75. videoMediaState = { _isVideoMuted ? MEDIA_STATE.MUTED : MEDIA_STATE.UNMUTED } />
  76. );
  77. }
  78. /**
  79. * Maps (parts of) the redux state to the associated props for this component.
  80. *
  81. * @param {Object} state - The Redux state.
  82. * @param {Object} ownProps - The own props of the component.
  83. * @private
  84. * @returns {Props}
  85. */
  86. function mapStateToProps(state, ownProps): Object {
  87. const { participantID } = ownProps;
  88. const participant = getParticipantByIdOrUndefined(state, participantID);
  89. const _isAudioMuted = isParticipantAudioMuted(participant, state);
  90. const isVideoMuted = isParticipantVideoMuted(participant, state);
  91. const audioMediaState = getParticipantAudioMediaState(
  92. participant, _isAudioMuted, state
  93. );
  94. return {
  95. _audioMediaState: audioMediaState,
  96. _displayName: getParticipantDisplayName(state, participant?.id),
  97. _isAudioMuted,
  98. _isVideoMuted: isVideoMuted,
  99. _local: Boolean(participant?.local),
  100. _participantID: participant?.id,
  101. _raisedHand: Boolean(participant?.raisedHand)
  102. };
  103. }
  104. export default translate(connect(mapStateToProps)(MeetingParticipantItem));