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.4KB

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