thumbnail: use a functional component
Simplifies the code a bit, and we use no lifecycle methods.
This commit is contained in:
parent
d1be5742ba
commit
bcc1be675f
|
@ -1,6 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
import React from 'react';
|
||||||
import { View } from 'react-native';
|
import { View } from 'react-native';
|
||||||
import type { Dispatch } from 'redux';
|
import type { Dispatch } from 'redux';
|
||||||
|
|
||||||
|
@ -111,93 +111,86 @@ type Props = {
|
||||||
/**
|
/**
|
||||||
* React component for video thumbnail.
|
* React component for video thumbnail.
|
||||||
*
|
*
|
||||||
* @extends Component
|
* @param {Props} props - Properties passed to this functional component.
|
||||||
|
* @returns {Component} - A React component.
|
||||||
*/
|
*/
|
||||||
class Thumbnail extends Component<Props> {
|
function Thumbnail(props: Props) {
|
||||||
/**
|
const {
|
||||||
* Implements React's {@link Component#render()}.
|
_audioMuted: audioMuted,
|
||||||
*
|
_largeVideo: largeVideo,
|
||||||
* @inheritdoc
|
_onClick,
|
||||||
* @returns {ReactElement}
|
_onShowRemoteVideoMenu,
|
||||||
*/
|
_renderDominantSpeakerIndicator: renderDominantSpeakerIndicator,
|
||||||
render() {
|
_renderModeratorIndicator: renderModeratorIndicator,
|
||||||
const {
|
_styles,
|
||||||
_audioMuted: audioMuted,
|
_videoTrack: videoTrack,
|
||||||
_largeVideo: largeVideo,
|
disableTint,
|
||||||
_onClick,
|
participant,
|
||||||
_onShowRemoteVideoMenu,
|
renderDisplayName,
|
||||||
_renderDominantSpeakerIndicator: renderDominantSpeakerIndicator,
|
tileView
|
||||||
_renderModeratorIndicator: renderModeratorIndicator,
|
} = props;
|
||||||
_styles,
|
|
||||||
_videoTrack: videoTrack,
|
|
||||||
disableTint,
|
|
||||||
participant,
|
|
||||||
renderDisplayName,
|
|
||||||
tileView
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
const participantId = participant.id;
|
const participantId = participant.id;
|
||||||
const participantInLargeVideo
|
const participantInLargeVideo
|
||||||
= participantId === largeVideo.participantId;
|
= participantId === largeVideo.participantId;
|
||||||
const videoMuted = !videoTrack || videoTrack.muted;
|
const videoMuted = !videoTrack || videoTrack.muted;
|
||||||
const isScreenShare = videoTrack && videoTrack.videoType === VIDEO_TYPE.DESKTOP;
|
const isScreenShare = videoTrack && videoTrack.videoType === VIDEO_TYPE.DESKTOP;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container
|
<Container
|
||||||
onClick = { _onClick }
|
onClick = { _onClick }
|
||||||
onLongPress = { participant.local ? undefined : _onShowRemoteVideoMenu }
|
onLongPress = { participant.local ? undefined : _onShowRemoteVideoMenu }
|
||||||
|
style = { [
|
||||||
|
styles.thumbnail,
|
||||||
|
participant.pinned && !tileView
|
||||||
|
? _styles.thumbnailPinned : null,
|
||||||
|
this.props.styleOverrides || null
|
||||||
|
] }
|
||||||
|
touchFeedback = { false }>
|
||||||
|
|
||||||
|
<ParticipantView
|
||||||
|
avatarSize = { AVATAR_SIZE }
|
||||||
|
disableVideo = { isScreenShare }
|
||||||
|
participantId = { participantId }
|
||||||
|
style = { _styles.participantViewStyle }
|
||||||
|
tintEnabled = { participantInLargeVideo && !disableTint }
|
||||||
|
tintStyle = { _styles.activeThumbnailTint }
|
||||||
|
zOrder = { 1 } />
|
||||||
|
|
||||||
|
{ renderDisplayName && <DisplayNameLabel participantId = { participantId } /> }
|
||||||
|
|
||||||
|
{ renderModeratorIndicator
|
||||||
|
&& <View style = { styles.moderatorIndicatorContainer }>
|
||||||
|
<ModeratorIndicator />
|
||||||
|
</View> }
|
||||||
|
|
||||||
|
<View
|
||||||
style = { [
|
style = { [
|
||||||
styles.thumbnail,
|
styles.thumbnailTopIndicatorContainer,
|
||||||
participant.pinned && !tileView
|
styles.thumbnailTopLeftIndicatorContainer
|
||||||
? _styles.thumbnailPinned : null,
|
] }>
|
||||||
this.props.styleOverrides || null
|
<RaisedHandIndicator participantId = { participant.id } />
|
||||||
] }
|
{ renderDominantSpeakerIndicator && <DominantSpeakerIndicator /> }
|
||||||
touchFeedback = { false }>
|
</View>
|
||||||
|
|
||||||
<ParticipantView
|
<View
|
||||||
avatarSize = { AVATAR_SIZE }
|
style = { [
|
||||||
disableVideo = { isScreenShare }
|
styles.thumbnailTopIndicatorContainer,
|
||||||
participantId = { participantId }
|
styles.thumbnailTopRightIndicatorContainer
|
||||||
style = { _styles.participantViewStyle }
|
] }>
|
||||||
tintEnabled = { participantInLargeVideo && !disableTint }
|
<ConnectionIndicator participantId = { participant.id } />
|
||||||
tintStyle = { _styles.activeThumbnailTint }
|
</View>
|
||||||
zOrder = { 1 } />
|
|
||||||
|
|
||||||
{ renderDisplayName && <DisplayNameLabel participantId = { participantId } /> }
|
<Container style = { styles.thumbnailIndicatorContainer }>
|
||||||
|
{ audioMuted
|
||||||
{ renderModeratorIndicator
|
&& <AudioMutedIndicator /> }
|
||||||
&& <View style = { styles.moderatorIndicatorContainer }>
|
|
||||||
<ModeratorIndicator />
|
|
||||||
</View> }
|
|
||||||
|
|
||||||
<View
|
|
||||||
style = { [
|
|
||||||
styles.thumbnailTopIndicatorContainer,
|
|
||||||
styles.thumbnailTopLeftIndicatorContainer
|
|
||||||
] }>
|
|
||||||
<RaisedHandIndicator participantId = { participant.id } />
|
|
||||||
{ renderDominantSpeakerIndicator && <DominantSpeakerIndicator /> }
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<View
|
|
||||||
style = { [
|
|
||||||
styles.thumbnailTopIndicatorContainer,
|
|
||||||
styles.thumbnailTopRightIndicatorContainer
|
|
||||||
] }>
|
|
||||||
<ConnectionIndicator participantId = { participant.id } />
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<Container style = { styles.thumbnailIndicatorContainer }>
|
|
||||||
{ audioMuted
|
|
||||||
&& <AudioMutedIndicator /> }
|
|
||||||
|
|
||||||
{ videoMuted
|
|
||||||
&& <VideoMutedIndicator /> }
|
|
||||||
</Container>
|
|
||||||
|
|
||||||
|
{ videoMuted
|
||||||
|
&& <VideoMutedIndicator /> }
|
||||||
</Container>
|
</Container>
|
||||||
);
|
|
||||||
}
|
</Container>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue