2018-09-13 15:20:22 +00:00
|
|
|
// @flow
|
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2022-03-30 13:54:03 +00:00
|
|
|
import { Image, View } from 'react-native';
|
2019-03-19 15:42:25 +00:00
|
|
|
import type { Dispatch } from 'redux';
|
2016-10-05 14:36:59 +00:00
|
|
|
|
2019-09-13 10:00:08 +00:00
|
|
|
import { MEDIA_TYPE, VIDEO_TYPE } from '../../../base/media';
|
2017-02-27 20:37:53 +00:00
|
|
|
import {
|
|
|
|
PARTICIPANT_ROLE,
|
|
|
|
ParticipantView,
|
2019-09-12 13:03:20 +00:00
|
|
|
getParticipantCount,
|
2019-05-22 10:00:17 +00:00
|
|
|
isEveryoneModerator,
|
2021-07-09 12:36:19 +00:00
|
|
|
pinParticipant,
|
2021-08-04 08:51:05 +00:00
|
|
|
getParticipantByIdOrUndefined,
|
2021-12-20 08:44:22 +00:00
|
|
|
getLocalParticipant,
|
|
|
|
hasRaisedHand
|
2018-05-10 23:01:55 +00:00
|
|
|
} from '../../../base/participants';
|
|
|
|
import { Container } from '../../../base/react';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../../base/redux';
|
2018-05-10 23:01:55 +00:00
|
|
|
import { getTrackByMediaTypeAndParticipant } from '../../../base/tracks';
|
2019-04-15 16:23:28 +00:00
|
|
|
import { ConnectionIndicator } from '../../../connection-indicator';
|
2019-04-11 10:04:50 +00:00
|
|
|
import { DisplayNameLabel } from '../../../display-name';
|
2022-03-30 13:54:03 +00:00
|
|
|
import { getGifDisplayMode, getGifForParticipant } from '../../../gifs/functions';
|
2022-01-07 14:12:27 +00:00
|
|
|
import {
|
|
|
|
showContextMenuDetails,
|
|
|
|
showSharedVideoMenu
|
|
|
|
} from '../../../participants-pane/actions.native';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { toggleToolboxVisible } from '../../../toolbox/actions.native';
|
2021-08-20 23:32:38 +00:00
|
|
|
import { SQUARE_TILE_ASPECT_RATIO } from '../../constants';
|
2018-12-19 18:40:17 +00:00
|
|
|
|
2018-05-10 23:01:55 +00:00
|
|
|
import AudioMutedIndicator from './AudioMutedIndicator';
|
|
|
|
import ModeratorIndicator from './ModeratorIndicator';
|
2022-03-31 11:39:49 +00:00
|
|
|
import PinnedIndicator from './PinnedIndicator';
|
2019-03-27 10:23:41 +00:00
|
|
|
import RaisedHandIndicator from './RaisedHandIndicator';
|
2020-07-16 15:03:15 +00:00
|
|
|
import ScreenShareIndicator from './ScreenShareIndicator';
|
2020-05-20 10:57:03 +00:00
|
|
|
import styles, { AVATAR_SIZE } from './styles';
|
2018-02-05 10:57:40 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
2018-09-13 15:20:22 +00:00
|
|
|
* Thumbnail component's property types.
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2018-09-13 15:20:22 +00:00
|
|
|
type Props = {
|
|
|
|
|
2016-12-01 01:52:39 +00:00
|
|
|
/**
|
2019-09-13 10:00:08 +00:00
|
|
|
* Whether local audio (microphone) is muted or not.
|
2018-09-13 15:20:22 +00:00
|
|
|
*/
|
2019-09-13 10:00:08 +00:00
|
|
|
_audioMuted: boolean,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
2022-03-30 13:54:03 +00:00
|
|
|
/**
|
|
|
|
* URL of GIF sent by this participant, null if there's none.
|
|
|
|
*/
|
|
|
|
_gifSrc: ?string,
|
|
|
|
|
2018-09-13 15:20:22 +00:00
|
|
|
/**
|
2021-08-20 23:32:38 +00:00
|
|
|
* Indicates whether the participant is fake.
|
2018-09-13 15:20:22 +00:00
|
|
|
*/
|
2021-08-20 23:32:38 +00:00
|
|
|
_isFakeParticipant: boolean,
|
|
|
|
|
|
|
|
/**
|
2021-08-26 23:23:38 +00:00
|
|
|
* Indicates whether the participant is screen sharing.
|
2021-08-20 23:32:38 +00:00
|
|
|
*/
|
|
|
|
_isScreenShare: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the participant is local.
|
|
|
|
*/
|
|
|
|
_local: boolean,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
2021-08-04 08:51:05 +00:00
|
|
|
/**
|
|
|
|
* Shared video local participant owner.
|
|
|
|
*/
|
|
|
|
_localVideoOwner: boolean,
|
|
|
|
|
2019-01-05 16:49:21 +00:00
|
|
|
/**
|
2021-08-20 23:32:38 +00:00
|
|
|
* The ID of the participant obtain from the participant object in Redux.
|
|
|
|
*
|
|
|
|
* NOTE: Generally it should be the same as the participantID prop except the case where the passed
|
|
|
|
* participantID doesn't corespond to any of the existing participants.
|
|
|
|
*/
|
|
|
|
_participantId: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicates whether the participant is pinned or not.
|
2019-01-05 16:49:21 +00:00
|
|
|
*/
|
2021-08-20 23:32:38 +00:00
|
|
|
_pinned: boolean,
|
2019-01-05 16:49:21 +00:00
|
|
|
|
2021-12-20 08:44:22 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the participant has the hand raised.
|
|
|
|
*/
|
|
|
|
_raisedHand: boolean,
|
|
|
|
|
2019-09-12 13:03:20 +00:00
|
|
|
/**
|
|
|
|
* Whether to show the dominant speaker indicator or not.
|
|
|
|
*/
|
2019-09-13 09:51:49 +00:00
|
|
|
_renderDominantSpeakerIndicator: boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether to show the moderator indicator or not.
|
|
|
|
*/
|
|
|
|
_renderModeratorIndicator: boolean,
|
2019-09-12 13:03:20 +00:00
|
|
|
|
2018-09-13 15:20:22 +00:00
|
|
|
/**
|
|
|
|
* Invoked to trigger state changes in Redux.
|
|
|
|
*/
|
2019-03-19 15:42:25 +00:00
|
|
|
dispatch: Dispatch<any>,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
/**
|
|
|
|
* The height of the thumnail.
|
|
|
|
*/
|
|
|
|
height: ?number,
|
|
|
|
|
2018-09-13 15:20:22 +00:00
|
|
|
/**
|
2021-07-09 12:36:19 +00:00
|
|
|
* The ID of the participant related to the thumbnail.
|
2018-09-13 15:20:22 +00:00
|
|
|
*/
|
2021-07-09 12:36:19 +00:00
|
|
|
participantID: ?string,
|
2018-09-13 15:20:22 +00:00
|
|
|
|
2019-04-11 10:04:50 +00:00
|
|
|
/**
|
|
|
|
* Whether to display or hide the display name of the participant in the thumbnail.
|
|
|
|
*/
|
|
|
|
renderDisplayName: ?boolean,
|
|
|
|
|
2019-06-19 12:44:39 +00:00
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* If true, it tells the thumbnail that it needs to behave differently. E.g. React differently to a single tap.
|
2019-06-19 12:44:39 +00:00
|
|
|
*/
|
|
|
|
tileView?: boolean
|
2018-09-13 15:20:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* React component for video thumbnail.
|
|
|
|
*/
|
2021-08-20 23:32:38 +00:00
|
|
|
class Thumbnail extends PureComponent<Props> {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates new Thumbnail component.
|
|
|
|
*
|
|
|
|
* @param {Props} props - The props of the component.
|
|
|
|
* @returns {Thumbnail}
|
|
|
|
*/
|
|
|
|
constructor(props: Props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this._onClick = this._onClick.bind(this);
|
|
|
|
this._onThumbnailLongPress = this._onThumbnailLongPress.bind(this);
|
2021-08-23 23:02:41 +00:00
|
|
|
}
|
|
|
|
|
2021-08-20 23:32:38 +00:00
|
|
|
_onClick: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thumbnail click handler.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onClick() {
|
|
|
|
const { _participantId, _pinned, dispatch, tileView } = this.props;
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
if (tileView) {
|
|
|
|
dispatch(toggleToolboxVisible());
|
|
|
|
} else {
|
2021-08-20 23:32:38 +00:00
|
|
|
dispatch(pinParticipant(_pinned ? null : _participantId));
|
2021-07-09 12:36:19 +00:00
|
|
|
}
|
2021-08-20 23:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_onThumbnailLongPress: () => void;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thumbnail long press handler.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_onThumbnailLongPress() {
|
|
|
|
const { _participantId, _local, _isFakeParticipant, _localVideoOwner, dispatch } = this.props;
|
|
|
|
|
2022-01-07 14:12:27 +00:00
|
|
|
if (_isFakeParticipant && _localVideoOwner) {
|
|
|
|
dispatch(showSharedVideoMenu(_participantId));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_isFakeParticipant) {
|
2022-01-28 10:47:54 +00:00
|
|
|
dispatch(showContextMenuDetails(_participantId, _local));
|
2021-07-09 12:36:19 +00:00
|
|
|
}
|
2021-08-20 23:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-26 23:23:38 +00:00
|
|
|
* Renders the indicators for the thumbnail.
|
2021-08-20 23:32:38 +00:00
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
2021-08-26 23:23:38 +00:00
|
|
|
_renderIndicators() {
|
2021-08-20 23:32:38 +00:00
|
|
|
const {
|
|
|
|
_audioMuted: audioMuted,
|
|
|
|
_isScreenShare: isScreenShare,
|
|
|
|
_isFakeParticipant,
|
|
|
|
_renderModeratorIndicator: renderModeratorIndicator,
|
|
|
|
_participantId: participantId,
|
2022-03-31 11:39:49 +00:00
|
|
|
_pinned,
|
|
|
|
renderDisplayName,
|
|
|
|
tileView
|
2021-08-26 23:23:38 +00:00
|
|
|
} = this.props;
|
|
|
|
const indicators = [];
|
|
|
|
|
|
|
|
if (!_isFakeParticipant) {
|
|
|
|
indicators.push(<View
|
2021-09-01 11:04:51 +00:00
|
|
|
key = 'top-left-indicators'
|
2021-08-26 23:23:38 +00:00
|
|
|
style = { [
|
|
|
|
styles.thumbnailTopIndicatorContainer,
|
|
|
|
styles.thumbnailTopLeftIndicatorContainer
|
|
|
|
] }>
|
|
|
|
<ConnectionIndicator participantId = { participantId } />
|
2022-02-14 10:13:18 +00:00
|
|
|
<RaisedHandIndicator participantId = { participantId } />
|
2022-03-31 11:39:49 +00:00
|
|
|
{tileView && isScreenShare && (
|
2022-02-14 10:13:18 +00:00
|
|
|
<View style = { styles.indicatorContainer }>
|
|
|
|
<ScreenShareIndicator />
|
|
|
|
</View>
|
|
|
|
)}
|
2021-08-26 23:23:38 +00:00
|
|
|
</View>);
|
2021-09-01 11:04:51 +00:00
|
|
|
indicators.push(<Container
|
|
|
|
key = 'bottom-indicators'
|
|
|
|
style = { styles.thumbnailIndicatorContainer }>
|
2022-02-24 12:17:02 +00:00
|
|
|
<Container style = { (audioMuted || renderModeratorIndicator) && styles.bottomIndicatorsContainer }>
|
|
|
|
{ audioMuted && <AudioMutedIndicator /> }
|
2022-03-31 11:39:49 +00:00
|
|
|
{ !tileView && _pinned && <PinnedIndicator />}
|
2022-02-24 12:17:02 +00:00
|
|
|
{ renderModeratorIndicator && <ModeratorIndicator />}
|
2022-03-31 11:39:49 +00:00
|
|
|
{ !tileView && isScreenShare
|
|
|
|
&& <ScreenShareIndicator />
|
|
|
|
}
|
2022-02-24 12:17:02 +00:00
|
|
|
</Container>
|
2022-02-23 13:46:38 +00:00
|
|
|
{
|
|
|
|
renderDisplayName && <DisplayNameLabel
|
|
|
|
contained = { true }
|
|
|
|
participantId = { participantId } />
|
|
|
|
}
|
2021-08-26 23:23:38 +00:00
|
|
|
</Container>);
|
|
|
|
}
|
|
|
|
|
|
|
|
return indicators;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements React's {@link Component#render()}.
|
|
|
|
*
|
|
|
|
* @inheritdoc
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
render() {
|
|
|
|
const {
|
2022-03-30 13:54:03 +00:00
|
|
|
_gifSrc,
|
2021-08-26 23:23:38 +00:00
|
|
|
_isScreenShare: isScreenShare,
|
|
|
|
_isFakeParticipant,
|
|
|
|
_participantId: participantId,
|
2021-12-20 08:44:22 +00:00
|
|
|
_raisedHand,
|
2022-02-14 10:13:18 +00:00
|
|
|
_renderDominantSpeakerIndicator,
|
2021-08-20 23:32:38 +00:00
|
|
|
height,
|
|
|
|
tileView
|
|
|
|
} = this.props;
|
|
|
|
const styleOverrides = tileView ? {
|
|
|
|
aspectRatio: SQUARE_TILE_ASPECT_RATIO,
|
|
|
|
flex: 0,
|
|
|
|
height,
|
|
|
|
maxHeight: null,
|
|
|
|
maxWidth: null,
|
|
|
|
width: null
|
|
|
|
} : null;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Container
|
|
|
|
onClick = { this._onClick }
|
|
|
|
onLongPress = { this._onThumbnailLongPress }
|
2019-09-13 10:06:02 +00:00
|
|
|
style = { [
|
2021-08-20 23:32:38 +00:00
|
|
|
styles.thumbnail,
|
2021-12-20 08:44:22 +00:00
|
|
|
styleOverrides,
|
2022-02-14 10:13:18 +00:00
|
|
|
_raisedHand ? styles.thumbnailRaisedHand : null,
|
|
|
|
_renderDominantSpeakerIndicator ? styles.thumbnailDominantSpeaker : null
|
2021-08-20 23:32:38 +00:00
|
|
|
] }
|
|
|
|
touchFeedback = { false }>
|
2022-03-30 13:54:03 +00:00
|
|
|
{_gifSrc ? <Image
|
|
|
|
source = {{ uri: _gifSrc }}
|
|
|
|
style = { styles.thumbnailGif } />
|
|
|
|
: <>
|
|
|
|
<ParticipantView
|
|
|
|
avatarSize = { tileView ? AVATAR_SIZE * 1.5 : AVATAR_SIZE }
|
|
|
|
disableVideo = { isScreenShare || _isFakeParticipant }
|
|
|
|
participantId = { participantId }
|
|
|
|
zOrder = { 1 } />
|
|
|
|
{
|
|
|
|
this._renderIndicators()
|
|
|
|
}
|
|
|
|
</>
|
2021-08-20 23:32:38 +00:00
|
|
|
}
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
2019-01-05 16:49:21 +00:00
|
|
|
}
|
2017-01-28 23:28:13 +00:00
|
|
|
|
2016-10-05 14:36:59 +00:00
|
|
|
/**
|
|
|
|
* Function that maps parts of Redux state tree into component props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - Redux state.
|
2019-01-05 16:49:21 +00:00
|
|
|
* @param {Props} ownProps - Properties of component.
|
2019-09-12 13:03:20 +00:00
|
|
|
* @returns {Object}
|
2016-10-05 14:36:59 +00:00
|
|
|
*/
|
2017-01-28 23:34:57 +00:00
|
|
|
function _mapStateToProps(state, ownProps) {
|
2021-08-04 08:51:05 +00:00
|
|
|
const { ownerId } = state['features/shared-video'];
|
2016-10-05 14:36:59 +00:00
|
|
|
const tracks = state['features/base/tracks'];
|
2022-03-31 11:39:49 +00:00
|
|
|
const { participantID, tileView } = ownProps;
|
2021-07-09 12:36:19 +00:00
|
|
|
const participant = getParticipantByIdOrUndefined(state, participantID);
|
2021-08-04 08:51:05 +00:00
|
|
|
const localParticipantId = getLocalParticipant(state).id;
|
2021-07-09 12:36:19 +00:00
|
|
|
const id = participant?.id;
|
2016-10-05 14:36:59 +00:00
|
|
|
const audioTrack
|
|
|
|
= getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.AUDIO, id);
|
|
|
|
const videoTrack
|
|
|
|
= getTrackByMediaTypeAndParticipant(tracks, MEDIA_TYPE.VIDEO, id);
|
2021-08-26 23:26:41 +00:00
|
|
|
const isScreenShare = videoTrack?.videoType === VIDEO_TYPE.DESKTOP;
|
2019-09-12 13:03:20 +00:00
|
|
|
const participantCount = getParticipantCount(state);
|
2021-07-09 12:36:19 +00:00
|
|
|
const renderDominantSpeakerIndicator = participant && participant.dominantSpeaker && participantCount > 2;
|
2019-09-13 09:51:49 +00:00
|
|
|
const _isEveryoneModerator = isEveryoneModerator(state);
|
2022-03-31 11:39:49 +00:00
|
|
|
const renderModeratorIndicator = tileView && !_isEveryoneModerator
|
2021-08-26 23:26:41 +00:00
|
|
|
&& participant?.role === PARTICIPANT_ROLE.MODERATOR;
|
2022-03-30 13:54:03 +00:00
|
|
|
const { gifUrl: gifSrc } = getGifForParticipant(state, id);
|
|
|
|
const mode = getGifDisplayMode(state);
|
2016-10-05 14:36:59 +00:00
|
|
|
|
|
|
|
return {
|
2019-09-13 10:00:08 +00:00
|
|
|
_audioMuted: audioTrack?.muted ?? true,
|
2022-03-30 13:54:03 +00:00
|
|
|
_gifSrc: mode === 'chat' ? null : gifSrc,
|
2021-08-20 23:32:38 +00:00
|
|
|
_isFakeParticipant: participant?.isFakeParticipant,
|
2021-08-30 14:50:24 +00:00
|
|
|
_isScreenShare: isScreenShare,
|
2021-08-20 23:32:38 +00:00
|
|
|
_local: participant?.local,
|
2021-08-04 08:51:05 +00:00
|
|
|
_localVideoOwner: Boolean(ownerId === localParticipantId),
|
2021-08-20 23:32:38 +00:00
|
|
|
_participantId: id,
|
|
|
|
_pinned: participant?.pinned,
|
2021-12-20 08:44:22 +00:00
|
|
|
_raisedHand: hasRaisedHand(participant),
|
2019-09-13 09:51:49 +00:00
|
|
|
_renderDominantSpeakerIndicator: renderDominantSpeakerIndicator,
|
2022-03-31 11:39:49 +00:00
|
|
|
_renderModeratorIndicator: renderModeratorIndicator
|
2016-10-05 14:36:59 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-09 12:36:19 +00:00
|
|
|
export default connect(_mapStateToProps)(Thumbnail);
|