您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ReactionsMenuButton.js 2.4KB

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