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 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // @flow
  2. import React, { PureComponent } from 'react';
  3. import { translate } from '../../../base/i18n';
  4. import {
  5. getLocalParticipant,
  6. getParticipantDisplayName,
  7. hasRaisedHand,
  8. isParticipantModerator
  9. } from '../../../base/participants';
  10. import { connect } from '../../../base/redux';
  11. import {
  12. isParticipantAudioMuted,
  13. isParticipantVideoMuted
  14. } from '../../../base/tracks';
  15. import { showConnectionStatus, showContextMenuDetails, showSharedVideoMenu } from '../../actions.native';
  16. import type { MediaState } from '../../constants';
  17. import { getParticipantAudioMediaState, getParticipantVideoMediaState } from '../../functions';
  18. import ParticipantItem from './ParticipantItem';
  19. type Props = {
  20. /**
  21. * Media state for audio.
  22. */
  23. _audioMediaState: MediaState,
  24. /**
  25. * Whether or not to disable the moderator indicator.
  26. */
  27. _disableModeratorIndicator: boolean,
  28. /**
  29. * The display name of the participant.
  30. */
  31. _displayName: string,
  32. /**
  33. * True if the participant is fake.
  34. */
  35. _isFakeParticipant: boolean,
  36. /**
  37. * Whether or not the user is a moderator.
  38. */
  39. _isModerator: boolean,
  40. /**
  41. * True if the participant is the local participant.
  42. */
  43. _local: boolean,
  44. /**
  45. * Shared video local participant owner.
  46. */
  47. _localVideoOwner: boolean,
  48. /**
  49. * The participant ID.
  50. */
  51. _participantID: string,
  52. /**
  53. * True if the participant have raised hand.
  54. */
  55. _raisedHand: boolean,
  56. /**
  57. * Media state for video.
  58. */
  59. _videoMediaState: MediaState,
  60. /**
  61. * The redux dispatch function.
  62. */
  63. dispatch: Function,
  64. /**
  65. * The participant.
  66. */
  67. participant: ?Object
  68. };
  69. /**
  70. * Implements the MeetingParticipantItem component.
  71. */
  72. class MeetingParticipantItem extends PureComponent<Props> {
  73. /**
  74. * Creates new MeetingParticipantItem instance.
  75. *
  76. * @param {Props} props - The props of the component.
  77. */
  78. constructor(props: Props) {
  79. super(props);
  80. this._onPress = this._onPress.bind(this);
  81. }
  82. _onPress: () => void;
  83. /**
  84. * Handles MeetingParticipantItem press events.
  85. *
  86. * @returns {void}
  87. */
  88. _onPress() {
  89. const {
  90. _local,
  91. _localVideoOwner,
  92. _isFakeParticipant,
  93. _participantID,
  94. dispatch
  95. } = this.props;
  96. if (_isFakeParticipant && _localVideoOwner) {
  97. dispatch(showSharedVideoMenu(_participantID));
  98. } else if (!_isFakeParticipant) {
  99. if (_local) {
  100. dispatch(showConnectionStatus(_participantID));
  101. } else {
  102. dispatch(showContextMenuDetails(_participantID));
  103. }
  104. } // else no-op
  105. }
  106. /**
  107. * Implements React's {@link Component#render()}.
  108. *
  109. * @inheritdoc
  110. * @returns {ReactElement}
  111. */
  112. render() {
  113. const {
  114. _audioMediaState,
  115. _disableModeratorIndicator,
  116. _displayName,
  117. _isModerator,
  118. _local,
  119. _participantID,
  120. _raisedHand,
  121. _videoMediaState
  122. } = this.props;
  123. return (
  124. <ParticipantItem
  125. audioMediaState = { _audioMediaState }
  126. disableModeratorIndicator = { _disableModeratorIndicator }
  127. displayName = { _displayName }
  128. isKnockingParticipant = { false }
  129. isModerator = { _isModerator }
  130. local = { _local }
  131. onPress = { this._onPress }
  132. participantID = { _participantID }
  133. raisedHand = { _raisedHand }
  134. videoMediaState = { _videoMediaState } />
  135. );
  136. }
  137. }
  138. /**
  139. * Maps (parts of) the redux state to the associated props for this component.
  140. *
  141. * @param {Object} state - The Redux state.
  142. * @param {Object} ownProps - The own props of the component.
  143. * @private
  144. * @returns {Props}
  145. */
  146. function mapStateToProps(state, ownProps): Object {
  147. const { participant } = ownProps;
  148. const { ownerId } = state['features/shared-video'];
  149. const localParticipantId = getLocalParticipant(state).id;
  150. const _isAudioMuted = isParticipantAudioMuted(participant, state);
  151. const _isVideoMuted = isParticipantVideoMuted(participant, state);
  152. const audioMediaState = getParticipantAudioMediaState(participant, _isAudioMuted, state);
  153. const videoMediaState = getParticipantVideoMediaState(participant, _isVideoMuted, state);
  154. const { disableModeratorIndicator } = state['features/base/config'];
  155. return {
  156. _audioMediaState: audioMediaState,
  157. _disableModeratorIndicator: disableModeratorIndicator,
  158. _displayName: getParticipantDisplayName(state, participant?.id),
  159. _isAudioMuted,
  160. _isFakeParticipant: Boolean(participant?.isFakeParticipant),
  161. _isModerator: isParticipantModerator(participant),
  162. _local: Boolean(participant?.local),
  163. _localVideoOwner: Boolean(ownerId === localParticipantId),
  164. _participantID: participant?.id,
  165. _raisedHand: hasRaisedHand(participant),
  166. _videoMediaState: videoMediaState
  167. };
  168. }
  169. export default translate(connect(mapStateToProps)(MeetingParticipantItem));