You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReactionsMenuButton.ts 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { connect } from 'react-redux';
  2. import { IReduxState } from '../../../app/types';
  3. import { openDialog } from '../../../base/dialog/actions';
  4. import { isDialogOpen } from '../../../base/dialog/functions';
  5. import { RAISE_HAND_ENABLED } from '../../../base/flags/constants';
  6. import { getFeatureFlag } from '../../../base/flags/functions';
  7. import { translate } from '../../../base/i18n/functions';
  8. import { IconRaiseHand } from '../../../base/icons/svg';
  9. import {
  10. getLocalParticipant, hasRaisedHand
  11. } from '../../../base/participants/functions';
  12. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  13. import ReactionMenuDialog from './ReactionMenuDialog';
  14. /**
  15. * The type of the React {@code Component} props of {@link ReactionsMenuButton}.
  16. */
  17. interface IProps extends AbstractButtonProps {
  18. /**
  19. * Whether the participant raised their hand or not.
  20. */
  21. _raisedHand: boolean;
  22. /**
  23. * Whether or not the reactions menu is open.
  24. */
  25. _reactionsOpen: boolean;
  26. }
  27. /**
  28. * An implementation of a button to raise or lower hand.
  29. */
  30. class ReactionsMenuButton extends AbstractButton<IProps> {
  31. accessibilityLabel = 'toolbar.accessibilityLabel.reactionsMenu';
  32. icon = IconRaiseHand;
  33. label = 'toolbar.openReactionsMenu';
  34. toggledLabel = 'toolbar.closeReactionsMenu';
  35. /**
  36. * Handles clicking / pressing the button.
  37. *
  38. * @override
  39. * @protected
  40. * @returns {void}
  41. */
  42. _handleClick() {
  43. this.props.dispatch(openDialog(ReactionMenuDialog));
  44. }
  45. /**
  46. * Indicates whether this button is in toggled state or not.
  47. *
  48. * @override
  49. * @protected
  50. * @returns {boolean}
  51. */
  52. _isToggled() {
  53. return this.props._raisedHand || this.props._reactionsOpen;
  54. }
  55. }
  56. /**
  57. * Maps part of the Redux state to the props of this component.
  58. *
  59. * @param {Object} state - The Redux state.
  60. * @param {Object} ownProps - The properties explicitly passed to the component instance.
  61. * @private
  62. * @returns {IProps}
  63. */
  64. function _mapStateToProps(state: IReduxState, ownProps: any) {
  65. const _localParticipant = getLocalParticipant(state);
  66. const enabled = getFeatureFlag(state, RAISE_HAND_ENABLED, true);
  67. const { visible = enabled } = ownProps;
  68. return {
  69. _raisedHand: hasRaisedHand(_localParticipant),
  70. _reactionsOpen: isDialogOpen(state, ReactionMenuDialog),
  71. visible
  72. };
  73. }
  74. export default translate(connect(_mapStateToProps)(ReactionsMenuButton));