2021-04-21 13:48:05 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-09-15 08:28:44 +00:00
|
|
|
import React, { useCallback, useEffect, useState } from 'react';
|
2021-04-21 13:48:05 +00:00
|
|
|
|
2021-09-22 13:26:55 +00:00
|
|
|
import { translate } from '../../../base/i18n';
|
2021-09-15 08:28:44 +00:00
|
|
|
import { JitsiTrackEvents } from '../../../base/lib-jitsi-meet';
|
|
|
|
import { MEDIA_TYPE } from '../../../base/media';
|
2021-08-04 08:51:05 +00:00
|
|
|
import {
|
|
|
|
getLocalParticipant,
|
|
|
|
getParticipantByIdOrUndefined,
|
2021-09-15 08:28:44 +00:00
|
|
|
getParticipantDisplayName,
|
2021-10-21 09:40:57 +00:00
|
|
|
hasRaisedHand,
|
2021-09-15 08:28:44 +00:00
|
|
|
isParticipantModerator
|
2021-08-04 08:51:05 +00:00
|
|
|
} from '../../../base/participants';
|
2021-07-12 15:14:38 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2021-09-15 08:28:44 +00:00
|
|
|
import {
|
|
|
|
getLocalAudioTrack,
|
|
|
|
getTrackByMediaTypeAndParticipant,
|
|
|
|
isParticipantAudioMuted,
|
|
|
|
isParticipantVideoMuted
|
|
|
|
} from '../../../base/tracks';
|
2022-09-27 07:10:28 +00:00
|
|
|
import { ACTION_TRIGGER, MEDIA_STATE, type MediaState } from '../../constants';
|
2021-09-10 11:05:16 +00:00
|
|
|
import {
|
|
|
|
getParticipantAudioMediaState,
|
|
|
|
getParticipantVideoMediaState,
|
2021-12-21 12:51:39 +00:00
|
|
|
getQuickActionButtonType,
|
|
|
|
participantMatchesSearch
|
2021-09-10 11:05:16 +00:00
|
|
|
} from '../../functions';
|
2021-04-21 13:48:05 +00:00
|
|
|
|
2021-10-22 13:23:52 +00:00
|
|
|
import ParticipantActionEllipsis from './ParticipantActionEllipsis';
|
2021-07-09 12:36:19 +00:00
|
|
|
import ParticipantItem from './ParticipantItem';
|
2021-10-22 13:23:52 +00:00
|
|
|
import ParticipantQuickAction from './ParticipantQuickAction';
|
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
type Props = {
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
|
|
|
* Media state for audio.
|
|
|
|
*/
|
|
|
|
_audioMediaState: MediaState,
|
|
|
|
|
2021-09-15 08:28:44 +00:00
|
|
|
/**
|
|
|
|
* The audio track related to the participant.
|
|
|
|
*/
|
|
|
|
_audioTrack: ?Object,
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
2021-09-28 08:46:20 +00:00
|
|
|
* Whether or not to disable the moderator indicator.
|
2021-07-09 12:36:19 +00:00
|
|
|
*/
|
2021-09-28 08:46:20 +00:00
|
|
|
_disableModeratorIndicator: boolean,
|
2021-07-09 12:36:19 +00:00
|
|
|
|
|
|
|
/**
|
2021-09-10 11:05:16 +00:00
|
|
|
* The display name of the participant.
|
2021-07-09 12:36:19 +00:00
|
|
|
*/
|
2021-09-10 11:05:16 +00:00
|
|
|
_displayName: string,
|
2021-07-09 12:36:19 +00:00
|
|
|
|
2021-10-01 13:47:13 +00:00
|
|
|
/**
|
|
|
|
* Whether or not moderation is supported.
|
|
|
|
*/
|
|
|
|
_isModerationSupported: boolean,
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
|
|
|
* True if the participant is the local participant.
|
|
|
|
*/
|
2021-09-14 15:31:30 +00:00
|
|
|
_local: boolean,
|
2021-07-09 12:36:19 +00:00
|
|
|
|
2021-10-01 13:47:13 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the local participant is moderator.
|
|
|
|
*/
|
|
|
|
_localModerator: boolean,
|
|
|
|
|
2021-08-04 08:51:05 +00:00
|
|
|
/**
|
|
|
|
* Shared video local participant owner.
|
|
|
|
*/
|
|
|
|
_localVideoOwner: boolean,
|
|
|
|
|
2021-10-21 11:58:44 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the participant name matches the search string.
|
|
|
|
*/
|
|
|
|
_matchesSearch: boolean,
|
|
|
|
|
2021-08-04 08:51:05 +00:00
|
|
|
/**
|
|
|
|
* The participant.
|
|
|
|
*/
|
|
|
|
_participant: Object,
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
|
|
|
* The participant ID.
|
|
|
|
*
|
|
|
|
* NOTE: This ID may be different from participantID prop in the case when we pass undefined for the local
|
2022-07-14 07:10:08 +00:00
|
|
|
* participant. In this case the local participant ID will be filled through _participantID prop.
|
2021-07-09 12:36:19 +00:00
|
|
|
*/
|
|
|
|
_participantID: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of button to be rendered for the quick action.
|
|
|
|
*/
|
|
|
|
_quickActionButtonType: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if the participant have raised hand.
|
|
|
|
*/
|
|
|
|
_raisedHand: boolean,
|
|
|
|
|
2021-09-28 08:46:20 +00:00
|
|
|
/**
|
|
|
|
* Media state for video.
|
|
|
|
*/
|
|
|
|
_videoMediaState: MediaState,
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
|
|
|
* The translated ask unmute text for the qiuck action buttons.
|
|
|
|
*/
|
|
|
|
askUnmuteText: string,
|
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Is this item highlighted.
|
2021-04-21 13:48:05 +00:00
|
|
|
*/
|
|
|
|
isHighlighted: boolean,
|
|
|
|
|
2022-02-14 14:47:14 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the local participant is in a breakout room.
|
|
|
|
*/
|
|
|
|
isInBreakoutRoom: boolean,
|
|
|
|
|
2021-06-23 11:23:44 +00:00
|
|
|
/**
|
|
|
|
* Callback used to open a confirmation dialog for audio muting.
|
|
|
|
*/
|
|
|
|
muteAudio: Function,
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
|
|
|
* The translated text for the mute participant button.
|
|
|
|
*/
|
|
|
|
muteParticipantButtonText: string,
|
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Callback for the activation of this item's context menu.
|
2021-04-21 13:48:05 +00:00
|
|
|
*/
|
|
|
|
onContextMenu: Function,
|
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* Callback for the mouse leaving this item.
|
2021-04-21 13:48:05 +00:00
|
|
|
*/
|
|
|
|
onLeave: Function,
|
|
|
|
|
2021-09-10 11:05:16 +00:00
|
|
|
/**
|
|
|
|
* Callback used to open an actions drawer for a participant.
|
|
|
|
*/
|
|
|
|
openDrawerForParticipant: Function,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if an overflow drawer should be displayed.
|
|
|
|
*/
|
|
|
|
overflowDrawer: boolean,
|
|
|
|
|
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
/**
|
2021-07-09 12:36:19 +00:00
|
|
|
* The aria-label for the ellipsis action.
|
|
|
|
*/
|
|
|
|
participantActionEllipsisLabel: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The ID of the participant.
|
2021-04-21 13:48:05 +00:00
|
|
|
*/
|
2021-07-09 12:36:19 +00:00
|
|
|
participantID: ?string,
|
|
|
|
|
2021-09-22 13:26:55 +00:00
|
|
|
/**
|
|
|
|
* The translate function.
|
|
|
|
*/
|
|
|
|
t: Function,
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
|
|
|
* The translated "you" text.
|
|
|
|
*/
|
|
|
|
youText: string
|
2021-04-21 13:48:05 +00:00
|
|
|
};
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
/**
|
|
|
|
* Implements the MeetingParticipantItem component.
|
|
|
|
*
|
|
|
|
* @param {Props} props - The props of the component.
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
function MeetingParticipantItem({
|
|
|
|
_audioMediaState,
|
2021-09-15 08:28:44 +00:00
|
|
|
_audioTrack,
|
2021-09-28 08:46:20 +00:00
|
|
|
_disableModeratorIndicator,
|
2021-07-09 12:36:19 +00:00
|
|
|
_displayName,
|
|
|
|
_local,
|
2021-09-10 11:05:16 +00:00
|
|
|
_localVideoOwner,
|
2021-10-21 11:58:44 +00:00
|
|
|
_matchesSearch,
|
2021-08-04 08:51:05 +00:00
|
|
|
_participant,
|
2021-07-09 12:36:19 +00:00
|
|
|
_participantID,
|
|
|
|
_quickActionButtonType,
|
|
|
|
_raisedHand,
|
2021-09-28 08:46:20 +00:00
|
|
|
_videoMediaState,
|
2021-07-09 12:36:19 +00:00
|
|
|
askUnmuteText,
|
2021-04-21 13:48:05 +00:00
|
|
|
isHighlighted,
|
2022-02-14 14:47:14 +00:00
|
|
|
isInBreakoutRoom,
|
2021-06-23 11:23:44 +00:00
|
|
|
muteAudio,
|
2021-07-09 12:36:19 +00:00
|
|
|
muteParticipantButtonText,
|
2021-09-10 11:05:16 +00:00
|
|
|
onContextMenu,
|
|
|
|
onLeave,
|
|
|
|
openDrawerForParticipant,
|
|
|
|
overflowDrawer,
|
2021-07-09 12:36:19 +00:00
|
|
|
participantActionEllipsisLabel,
|
2021-09-22 13:26:55 +00:00
|
|
|
t,
|
2021-07-09 12:36:19 +00:00
|
|
|
youText
|
|
|
|
}: Props) {
|
2021-09-15 08:28:44 +00:00
|
|
|
|
|
|
|
const [ hasAudioLevels, setHasAudioLevel ] = useState(false);
|
|
|
|
const [ registeredEvent, setRegisteredEvent ] = useState(false);
|
|
|
|
|
|
|
|
const _updateAudioLevel = useCallback(level => {
|
|
|
|
const audioLevel = typeof level === 'number' && !isNaN(level)
|
|
|
|
? level : 0;
|
|
|
|
|
|
|
|
setHasAudioLevel(audioLevel > 0.009);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (_audioTrack && !registeredEvent) {
|
|
|
|
const { jitsiTrack } = _audioTrack;
|
|
|
|
|
|
|
|
if (jitsiTrack) {
|
|
|
|
jitsiTrack.on(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED, _updateAudioLevel);
|
|
|
|
setRegisteredEvent(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
if (_audioTrack && registeredEvent) {
|
|
|
|
const { jitsiTrack } = _audioTrack;
|
|
|
|
|
|
|
|
jitsiTrack && jitsiTrack.off(JitsiTrackEvents.TRACK_AUDIO_LEVEL_CHANGED, _updateAudioLevel);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}, [ _audioTrack ]);
|
|
|
|
|
2021-10-21 11:58:44 +00:00
|
|
|
if (!_matchesSearch) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-09-15 08:28:44 +00:00
|
|
|
const audioMediaState = _audioMediaState === MEDIA_STATE.UNMUTED && hasAudioLevels
|
|
|
|
? MEDIA_STATE.DOMINANT_SPEAKER : _audioMediaState;
|
|
|
|
|
2021-09-22 13:26:55 +00:00
|
|
|
let askToUnmuteText = askUnmuteText;
|
|
|
|
|
|
|
|
if (_audioMediaState !== MEDIA_STATE.FORCE_MUTED && _videoMediaState === MEDIA_STATE.FORCE_MUTED) {
|
|
|
|
askToUnmuteText = t('participantsPane.actions.allowVideo');
|
|
|
|
}
|
|
|
|
|
2021-04-21 13:48:05 +00:00
|
|
|
return (
|
|
|
|
<ParticipantItem
|
2021-06-23 11:23:44 +00:00
|
|
|
actionsTrigger = { ACTION_TRIGGER.HOVER }
|
2022-09-30 14:50:45 +00:00
|
|
|
{
|
|
|
|
...(_participant?.isFakeParticipant ? {} : {
|
|
|
|
audioMediaState,
|
|
|
|
videoMediaState: _videoMediaState
|
|
|
|
})
|
|
|
|
}
|
2021-09-28 08:46:20 +00:00
|
|
|
disableModeratorIndicator = { _disableModeratorIndicator }
|
2021-07-09 12:36:19 +00:00
|
|
|
displayName = { _displayName }
|
2021-04-21 13:48:05 +00:00
|
|
|
isHighlighted = { isHighlighted }
|
2021-09-15 08:28:44 +00:00
|
|
|
isModerator = { isParticipantModerator(_participant) }
|
2021-07-09 12:36:19 +00:00
|
|
|
local = { _local }
|
2021-04-21 13:48:05 +00:00
|
|
|
onLeave = { onLeave }
|
2021-09-10 11:05:16 +00:00
|
|
|
openDrawerForParticipant = { openDrawerForParticipant }
|
|
|
|
overflowDrawer = { overflowDrawer }
|
2021-07-09 12:36:19 +00:00
|
|
|
participantID = { _participantID }
|
|
|
|
raisedHand = { _raisedHand }
|
|
|
|
youText = { youText }>
|
2021-09-10 11:05:16 +00:00
|
|
|
|
2021-09-10 17:37:05 +00:00
|
|
|
{!overflowDrawer && !_participant?.isFakeParticipant
|
2021-09-10 11:05:16 +00:00
|
|
|
&& <>
|
2022-02-14 14:47:14 +00:00
|
|
|
{!isInBreakoutRoom && (
|
|
|
|
<ParticipantQuickAction
|
|
|
|
askUnmuteText = { askToUnmuteText }
|
|
|
|
buttonType = { _quickActionButtonType }
|
|
|
|
muteAudio = { muteAudio }
|
|
|
|
muteParticipantButtonText = { muteParticipantButtonText }
|
|
|
|
participantID = { _participantID }
|
|
|
|
participantName = { _displayName } />
|
|
|
|
)}
|
2021-08-04 08:51:05 +00:00
|
|
|
<ParticipantActionEllipsis
|
2021-10-22 13:23:52 +00:00
|
|
|
accessibilityLabel = { participantActionEllipsisLabel }
|
2021-08-04 08:51:05 +00:00
|
|
|
onClick = { onContextMenu } />
|
2021-09-15 08:28:44 +00:00
|
|
|
</>
|
2021-08-04 08:51:05 +00:00
|
|
|
}
|
2021-09-10 11:05:16 +00:00
|
|
|
|
2022-09-30 14:50:45 +00:00
|
|
|
{!overflowDrawer && (_localVideoOwner || _participant?.isWhiteboard) && _participant?.isFakeParticipant && (
|
2021-09-10 11:05:16 +00:00
|
|
|
<ParticipantActionEllipsis
|
2021-10-22 13:23:52 +00:00
|
|
|
accessibilityLabel = { participantActionEllipsisLabel }
|
2021-09-10 11:05:16 +00:00
|
|
|
onClick = { onContextMenu } />
|
|
|
|
)}
|
2021-04-21 13:48:05 +00:00
|
|
|
</ParticipantItem>
|
|
|
|
);
|
2021-07-09 12:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated props for this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @param {Object} ownProps - The own props of the component.
|
|
|
|
* @private
|
|
|
|
* @returns {Props}
|
|
|
|
*/
|
|
|
|
function _mapStateToProps(state, ownProps): Object {
|
2021-10-21 11:58:44 +00:00
|
|
|
const { participantID, searchString } = ownProps;
|
2021-08-04 08:51:05 +00:00
|
|
|
const { ownerId } = state['features/shared-video'];
|
|
|
|
const localParticipantId = getLocalParticipant(state).id;
|
2021-07-09 12:36:19 +00:00
|
|
|
|
|
|
|
const participant = getParticipantByIdOrUndefined(state, participantID);
|
|
|
|
|
2021-10-21 11:58:44 +00:00
|
|
|
const _displayName = getParticipantDisplayName(state, participant?.id);
|
|
|
|
|
2021-12-21 12:51:39 +00:00
|
|
|
const _matchesSearch = participantMatchesSearch(participant, searchString);
|
2021-10-21 11:58:44 +00:00
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
const _isAudioMuted = isParticipantAudioMuted(participant, state);
|
|
|
|
const _isVideoMuted = isParticipantVideoMuted(participant, state);
|
|
|
|
const _audioMediaState = getParticipantAudioMediaState(participant, _isAudioMuted, state);
|
2021-09-10 11:05:16 +00:00
|
|
|
const _videoMediaState = getParticipantVideoMediaState(participant, _isVideoMuted, state);
|
2021-07-09 12:36:19 +00:00
|
|
|
const _quickActionButtonType = getQuickActionButtonType(participant, _isAudioMuted, state);
|
|
|
|
|
2021-09-15 08:28:44 +00:00
|
|
|
const tracks = state['features/base/tracks'];
|
|
|
|
const _audioTrack = participantID === localParticipantId
|
|
|
|
? getLocalAudioTrack(tracks) : getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.AUDIO, participantID);
|
|
|
|
|
2021-09-28 08:46:20 +00:00
|
|
|
const { disableModeratorIndicator } = state['features/base/config'];
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
return {
|
|
|
|
_audioMediaState,
|
2021-09-15 08:28:44 +00:00
|
|
|
_audioTrack,
|
2021-09-28 08:46:20 +00:00
|
|
|
_disableModeratorIndicator: disableModeratorIndicator,
|
2021-10-21 11:58:44 +00:00
|
|
|
_displayName,
|
2021-07-09 12:36:19 +00:00
|
|
|
_local: Boolean(participant?.local),
|
2021-08-04 08:51:05 +00:00
|
|
|
_localVideoOwner: Boolean(ownerId === localParticipantId),
|
2021-10-21 11:58:44 +00:00
|
|
|
_matchesSearch,
|
2021-08-04 08:51:05 +00:00
|
|
|
_participant: participant,
|
2021-07-09 12:36:19 +00:00
|
|
|
_participantID: participant?.id,
|
|
|
|
_quickActionButtonType,
|
2021-10-21 09:40:57 +00:00
|
|
|
_raisedHand: hasRaisedHand(participant),
|
2021-09-28 08:46:20 +00:00
|
|
|
_videoMediaState
|
2021-07-09 12:36:19 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-09-22 13:26:55 +00:00
|
|
|
export default translate(connect(_mapStateToProps)(MeetingParticipantItem));
|