Files
jitsi-meet/react/features/video-menu/components/native/PinButton.ts
Robert Pintilii 1ba7765898 ref(TS) Convert some native components to TS (#13281)
Remove some @ts-ignores
2023-05-02 11:09:38 +03:00

60 lines
1.7 KiB
TypeScript

import { connect } from 'react-redux';
import { IReduxState } from '../../../app/types';
import { translate } from '../../../base/i18n/functions';
import { IconEnlarge } from '../../../base/icons/svg';
import { pinParticipant } from '../../../base/participants/actions';
import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
import { shouldDisplayTileView } from '../../../video-layout/functions';
export interface IProps extends AbstractButtonProps {
/**
* True if tile view is currently enabled.
*/
_tileViewEnabled?: boolean;
/**
* The ID of the participant that this button is supposed to pin.
*/
participantID: string;
}
/**
* A remote video menu button which pins a participant and exist the tile view.
*/
class PinButton extends AbstractButton<IProps> {
accessibilityLabel = 'toolbar.accessibilityLabel.show';
icon = IconEnlarge;
label = 'videothumbnail.show';
/**
* Handles clicking / pressing the button, and kicks the participant.
*
* @private
* @returns {void}
*/
_handleClick() {
const { dispatch } = this.props;
// Pin participant, it will automatically exit the tile view
dispatch(pinParticipant(this.props.participantID));
}
}
/**
* Maps part of the Redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @returns {IProps}
*/
function _mapStateToProps(state: IReduxState) {
const { isOpen } = state['features/participants-pane'];
return {
visible: !isOpen && shouldDisplayTileView(state)
};
}
export default translate(connect(_mapStateToProps)(PinButton));