2019-03-27 14:47:19 +01:00
|
|
|
// @flow
|
|
|
|
|
|
2023-03-21 09:47:52 +02:00
|
|
|
import { connect } from 'react-redux';
|
2019-03-27 14:47:19 +01:00
|
|
|
import { type Dispatch } from 'redux';
|
|
|
|
|
|
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';
|
2019-03-27 14:47:19 +01:00
|
|
|
import { translate } from '../../../base/i18n';
|
2022-11-08 12:24:32 +02:00
|
|
|
import { IconRaiseHand } from '../../../base/icons';
|
2019-03-27 14:47:19 +01:00
|
|
|
import {
|
2021-10-21 12:40:57 +03:00
|
|
|
getLocalParticipant, hasRaisedHand
|
2019-03-27 14:47:19 +01:00
|
|
|
} from '../../../base/participants';
|
2020-07-24 14:14:33 +02:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
|
2019-03-27 14:47:19 +01:00
|
|
|
|
2021-07-13 09:50:08 +03:00
|
|
|
import ReactionMenuDialog from './ReactionMenuDialog';
|
|
|
|
|
|
2019-03-27 14:47:19 +01:00
|
|
|
/**
|
2021-07-13 09:50:08 +03:00
|
|
|
* The type of the React {@code Component} props of {@link ReactionsMenuButton}.
|
2019-03-27 14:47:19 +01:00
|
|
|
*/
|
|
|
|
|
type Props = AbstractButtonProps & {
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-13 09:50:08 +03:00
|
|
|
* Whether the participant raised their hand or not.
|
2019-03-27 14:47:19 +01:00
|
|
|
*/
|
2021-07-13 09:50:08 +03:00
|
|
|
_raisedHand: boolean,
|
2019-03-27 14:47:19 +01:00
|
|
|
|
|
|
|
|
/**
|
2021-07-13 09:50:08 +03:00
|
|
|
* Whether or not the reactions menu is open.
|
2019-03-27 14:47:19 +01:00
|
|
|
*/
|
2021-07-13 09:50:08 +03:00
|
|
|
_reactionsOpen: boolean,
|
2019-03-27 14:47:19 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The redux {@code dispatch} function.
|
|
|
|
|
*/
|
|
|
|
|
dispatch: Dispatch<any>
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* An implementation of a button to raise or lower hand.
|
|
|
|
|
*/
|
2021-07-13 09:50:08 +03:00
|
|
|
class ReactionsMenuButton extends AbstractButton<Props, *> {
|
|
|
|
|
accessibilityLabel = 'toolbar.accessibilityLabel.reactionsMenu';
|
2022-11-08 12:24:32 +02:00
|
|
|
icon = IconRaiseHand;
|
2021-07-13 09:50:08 +03:00
|
|
|
label = 'toolbar.openReactionsMenu';
|
|
|
|
|
toggledLabel = 'toolbar.closeReactionsMenu';
|
2019-03-27 14:47:19 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles clicking / pressing the button.
|
|
|
|
|
*
|
|
|
|
|
* @override
|
|
|
|
|
* @protected
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
_handleClick() {
|
2021-07-13 09:50:08 +03:00
|
|
|
this.props.dispatch(openDialog(ReactionMenuDialog));
|
2019-03-27 14:47:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicates whether this button is in toggled state or not.
|
|
|
|
|
*
|
|
|
|
|
* @override
|
|
|
|
|
* @protected
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
|
|
|
|
_isToggled() {
|
2021-07-13 09:50:08 +03:00
|
|
|
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.
|
2020-05-04 21:52:45 +05:30
|
|
|
* @param {Object} ownProps - The properties explicitly passed to the component instance.
|
2019-03-27 14:47:19 +01:00
|
|
|
* @private
|
2020-05-04 21:52:45 +05:30
|
|
|
* @returns {Props}
|
2019-03-27 14:47:19 +01:00
|
|
|
*/
|
2020-05-04 21:52:45 +05:30
|
|
|
function _mapStateToProps(state, ownProps): Object {
|
2019-03-27 14:47:19 +01:00
|
|
|
const _localParticipant = getLocalParticipant(state);
|
2020-05-04 21:52:45 +05:30
|
|
|
const enabled = getFeatureFlag(state, RAISE_HAND_ENABLED, true);
|
|
|
|
|
const { visible = enabled } = ownProps;
|
2019-03-27 14:47:19 +01:00
|
|
|
|
|
|
|
|
return {
|
2021-10-21 12:40:57 +03:00
|
|
|
_raisedHand: hasRaisedHand(_localParticipant),
|
2021-07-13 09:50:08 +03:00
|
|
|
_reactionsOpen: isDialogOpen(state, ReactionMenuDialog),
|
2020-05-04 21:52:45 +05:30
|
|
|
visible
|
2019-03-27 14:47:19 +01:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 09:50:08 +03:00
|
|
|
export default translate(connect(_mapStateToProps)(ReactionsMenuButton));
|