2022-03-29 08:45:09 +00:00
|
|
|
/* @flow */
|
|
|
|
|
|
|
|
import { makeStyles } from '@material-ui/styles';
|
|
|
|
import React from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
|
|
|
import { IconPinParticipant } from '../../../base/icons';
|
2022-04-05 13:00:32 +00:00
|
|
|
import { getParticipantById } from '../../../base/participants';
|
2022-03-29 08:45:09 +00:00
|
|
|
import { BaseIndicator } from '../../../base/react';
|
2022-06-17 12:15:14 +00:00
|
|
|
import { getPinnedActiveParticipants, isStageFilmstripAvailable } from '../../functions.web';
|
2022-03-29 08:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@link PinnedIndicator}.
|
|
|
|
*/
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The font-size for the icon.
|
|
|
|
*/
|
|
|
|
iconSize: number,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The participant id who we want to render the raised hand indicator
|
|
|
|
* for.
|
|
|
|
*/
|
|
|
|
participantId: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* From which side of the indicator the tooltip should appear from.
|
|
|
|
*/
|
|
|
|
tooltipPosition: string
|
|
|
|
};
|
|
|
|
|
|
|
|
const useStyles = makeStyles(() => {
|
|
|
|
return {
|
|
|
|
pinnedIndicator: {
|
|
|
|
backgroundColor: 'rgba(0, 0, 0, .7)',
|
|
|
|
padding: '2px',
|
|
|
|
zIndex: 3,
|
|
|
|
display: 'inline-block',
|
|
|
|
borderRadius: '4px',
|
|
|
|
boxSizing: 'border-box'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Thumbnail badge showing that the participant would like to speak.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
|
|
|
const PinnedIndicator = ({
|
|
|
|
iconSize,
|
|
|
|
participantId,
|
|
|
|
tooltipPosition
|
|
|
|
}: Props) => {
|
2022-06-17 12:15:14 +00:00
|
|
|
const stageFilmstrip = useSelector(isStageFilmstripAvailable);
|
2022-04-05 13:00:32 +00:00
|
|
|
const pinned = useSelector(state => getParticipantById(state, participantId))?.pinned;
|
|
|
|
const isPinned = useSelector(getPinnedActiveParticipants).find(p => p.participantId === participantId);
|
2022-03-29 08:45:09 +00:00
|
|
|
const styles = useStyles();
|
|
|
|
|
2022-04-05 13:00:32 +00:00
|
|
|
if ((stageFilmstrip && !isPinned) || (!stageFilmstrip && !pinned)) {
|
2022-03-29 08:45:09 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className = { styles.pinnedIndicator }>
|
|
|
|
<BaseIndicator
|
|
|
|
icon = { IconPinParticipant }
|
|
|
|
iconSize = { `${iconSize}px` }
|
|
|
|
tooltipKey = 'pinnedParticipant'
|
|
|
|
tooltipPosition = { tooltipPosition } />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PinnedIndicator;
|