Files
jitsi-meet/react/features/reactions/components/native/ReactionsMenuButton.ts

86 lines
2.6 KiB
TypeScript
Raw Normal View History

import { connect } from 'react-redux';
2019-03-27 14:47:19 +01:00
import { IReduxState } from '../../../app/types';
2023-03-31 14:04:33 +03:00
import { openDialog } from '../../../base/dialog/actions';
import { isDialogOpen } from '../../../base/dialog/functions';
import { RAISE_HAND_ENABLED } from '../../../base/flags/constants';
import { getFeatureFlag } from '../../../base/flags/functions';
import { translate } from '../../../base/i18n/functions';
import { IconRaiseHand } from '../../../base/icons/svg';
2019-03-27 14:47:19 +01:00
import {
getLocalParticipant, hasRaisedHand
} from '../../../base/participants/functions';
import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
2019-03-27 14:47:19 +01:00
import ReactionMenuDialog from './ReactionMenuDialog';
2019-03-27 14:47:19 +01:00
/**
* The type of the React {@code Component} props of {@link ReactionsMenuButton}.
2019-03-27 14:47:19 +01:00
*/
interface IProps extends AbstractButtonProps {
2019-03-27 14:47:19 +01:00
/**
* Whether the participant raised their hand or not.
2019-03-27 14:47:19 +01:00
*/
_raisedHand: boolean;
2019-03-27 14:47:19 +01:00
/**
* Whether or not the reactions menu is open.
2019-03-27 14:47:19 +01:00
*/
_reactionsOpen: boolean;
}
2019-03-27 14:47:19 +01:00
/**
* An implementation of a button to raise or lower hand.
*/
class ReactionsMenuButton extends AbstractButton<IProps> {
override accessibilityLabel = 'toolbar.accessibilityLabel.reactionsMenu';
override icon = IconRaiseHand;
override label = 'toolbar.openReactionsMenu';
override toggledLabel = 'toolbar.closeReactionsMenu';
2019-03-27 14:47:19 +01:00
/**
* Handles clicking / pressing the button.
*
* @override
* @protected
* @returns {void}
*/
override _handleClick() {
this.props.dispatch(openDialog('ReactionMenuDialog', ReactionMenuDialog));
2019-03-27 14:47:19 +01:00
}
/**
* Indicates whether this button is in toggled state or not.
*
* @override
* @protected
* @returns {boolean}
*/
override _isToggled() {
return this.props._raisedHand || this.props._reactionsOpen;
2019-03-27 14:47:19 +01:00
}
}
/**
* Maps part of the Redux state to the props of this component.
*
* @param {Object} state - The Redux state.
* @param {Object} ownProps - The properties explicitly passed to the component instance.
2019-03-27 14:47:19 +01:00
* @private
* @returns {IProps}
2019-03-27 14:47:19 +01:00
*/
function _mapStateToProps(state: IReduxState, ownProps: any) {
2019-03-27 14:47:19 +01:00
const _localParticipant = getLocalParticipant(state);
const enabled = getFeatureFlag(state, RAISE_HAND_ENABLED, true);
const { visible = enabled } = ownProps;
2019-03-27 14:47:19 +01:00
return {
_raisedHand: hasRaisedHand(_localParticipant),
_reactionsOpen: isDialogOpen(state, ReactionMenuDialog),
visible
2019-03-27 14:47:19 +01:00
};
}
export default translate(connect(_mapStateToProps)(ReactionsMenuButton));