2022-03-29 08:45:09 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
2022-09-13 07:36:00 +00:00
|
|
|
import { makeStyles } from 'tss-react/mui';
|
2022-03-29 08:45:09 +00:00
|
|
|
|
2022-10-20 09:11:27 +00:00
|
|
|
import { IReduxState } from '../../../app/types';
|
2022-11-08 10:24:32 +00:00
|
|
|
import { IconPin } from '../../../base/icons/svg';
|
2022-08-26 09:54:03 +00:00
|
|
|
import { getParticipantById } from '../../../base/participants/functions';
|
|
|
|
import BaseIndicator from '../../../base/react/components/web/BaseIndicator';
|
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}.
|
|
|
|
*/
|
2022-11-03 08:35:51 +00:00
|
|
|
interface IProps {
|
2022-03-29 08:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The font-size for the icon.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
iconSize: number;
|
2022-03-29 08:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The participant id who we want to render the raised hand indicator
|
|
|
|
* for.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
participantId: string;
|
2022-03-29 08:45:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* From which side of the indicator the tooltip should appear from.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
tooltipPosition: string;
|
2022-11-03 08:35:51 +00:00
|
|
|
}
|
2022-03-29 08:45:09 +00:00
|
|
|
|
2022-09-13 07:36:00 +00:00
|
|
|
const useStyles = makeStyles()(() => {
|
2022-03-29 08:45:09 +00:00
|
|
|
return {
|
|
|
|
pinnedIndicator: {
|
|
|
|
backgroundColor: 'rgba(0, 0, 0, .7)',
|
2022-11-10 08:22:57 +00:00
|
|
|
padding: '4px',
|
2022-03-29 08:45:09 +00:00
|
|
|
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
|
2022-11-03 08:35:51 +00:00
|
|
|
}: IProps) => {
|
2022-06-17 12:15:14 +00:00
|
|
|
const stageFilmstrip = useSelector(isStageFilmstripAvailable);
|
2022-10-20 09:11:27 +00:00
|
|
|
const pinned = useSelector((state: IReduxState) => getParticipantById(state, participantId))?.pinned;
|
2022-11-10 08:45:56 +00:00
|
|
|
const activePinnedParticipants: Array<{ participantId: string; pinned?: boolean; }>
|
2022-08-26 09:54:03 +00:00
|
|
|
= useSelector(getPinnedActiveParticipants);
|
|
|
|
const isPinned = activePinnedParticipants.find(p => p.participantId === participantId);
|
2022-09-13 07:36:00 +00:00
|
|
|
const { classes: styles } = useStyles();
|
2022-03-29 08:45:09 +00:00
|
|
|
|
2022-04-05 13:00:32 +00:00
|
|
|
if ((stageFilmstrip && !isPinned) || (!stageFilmstrip && !pinned)) {
|
2022-03-29 08:45:09 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-09-26 09:13:32 +00:00
|
|
|
<div
|
|
|
|
className = { styles.pinnedIndicator }
|
|
|
|
id = { `pin-indicator-${participantId}` }>
|
2022-03-29 08:45:09 +00:00
|
|
|
<BaseIndicator
|
2022-11-08 10:24:32 +00:00
|
|
|
icon = { IconPin }
|
2022-03-29 08:45:09 +00:00
|
|
|
iconSize = { `${iconSize}px` }
|
|
|
|
tooltipKey = 'pinnedParticipant'
|
|
|
|
tooltipPosition = { tooltipPosition } />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PinnedIndicator;
|