jiti-meet/react/features/video-menu/components/native/PinButton.js

70 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-06-19 13:32:09 +00:00
// @flow
import { translate } from '../../../base/i18n';
2019-08-30 16:39:06 +00:00
import { IconPin } from '../../../base/icons';
2019-06-19 13:32:09 +00:00
import { pinParticipant } from '../../../base/participants';
import { connect } from '../../../base/redux';
2020-07-24 12:14:33 +00:00
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
2020-07-23 13:12:25 +00:00
import { shouldDisplayTileView } from '../../../video-layout/functions';
2019-06-19 13:32:09 +00:00
export type Props = AbstractButtonProps & {
/**
* True if tile view is currently enabled.
*/
_tileViewEnabled: boolean,
/**
* The redux {@code dispatch} function.
*/
dispatch: Function,
/**
* The ID of the participant that this button is supposed to pin.
*/
participantID: string,
/**
* The function to be used to translate i18n labels.
*/
t: Function
};
/**
* A remote video menu button which pins a participant and exist the tile view.
*/
class PinButton extends AbstractButton<Props, *> {
accessibilityLabel = 'toolbar.accessibilityLabel.show';
2019-08-30 16:39:06 +00:00
icon = IconPin;
2019-06-19 13:32:09 +00:00
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 {Props}
*/
function _mapStateToProps(state) {
const { isOpen } = state['features/participants-pane'];
2019-06-19 13:32:09 +00:00
return {
visible: !isOpen && shouldDisplayTileView(state)
2019-06-19 13:32:09 +00:00
};
}
export default translate(connect(_mapStateToProps)(PinButton));