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.

RaiseHandButton.ts 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { connect } from 'react-redux';
  2. import { createToolbarEvent } from '../../../analytics/AnalyticsEvents';
  3. import { sendAnalytics } from '../../../analytics/functions';
  4. import { IReduxState } from '../../../app/types';
  5. import { translate } from '../../../base/i18n/functions';
  6. import { IconRaiseHand } from '../../../base/icons/svg';
  7. import { raiseHand } from '../../../base/participants/actions';
  8. import { getLocalParticipant, hasRaisedHand } from '../../../base/participants/functions';
  9. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  10. /**
  11. * The type of the React {@code Component} props of {@link RaiseHandButton}.
  12. */
  13. interface IProps extends AbstractButtonProps {
  14. /**
  15. * Whether or not the hand is raised.
  16. */
  17. raisedHand: boolean;
  18. }
  19. /**
  20. * Implementation of a button for raising hand.
  21. */
  22. class RaiseHandButton extends AbstractButton<IProps> {
  23. accessibilityLabel = 'toolbar.accessibilityLabel.raiseHand';
  24. toggledAccessibilityLabel = 'toolbar.accessibilityLabel.lowerHand';
  25. icon = IconRaiseHand;
  26. label = 'toolbar.raiseHand';
  27. toggledLabel = 'toolbar.lowerYourHand';
  28. tooltip = 'toolbar.raiseHand';
  29. toggledTooltip = 'toolbar.lowerYourHand';
  30. /**
  31. * Indicates whether this button is in toggled state or not.
  32. *
  33. * @override
  34. * @protected
  35. * @returns {boolean}
  36. */
  37. _isToggled() {
  38. return this.props.raisedHand;
  39. }
  40. /**
  41. * Handles clicking the button, and toggles the raise hand.
  42. *
  43. * @private
  44. * @returns {void}
  45. */
  46. _handleClick() {
  47. const { dispatch, raisedHand } = this.props;
  48. sendAnalytics(createToolbarEvent(
  49. 'raise.hand',
  50. { enable: !raisedHand }));
  51. dispatch(raiseHand(!raisedHand));
  52. }
  53. }
  54. /**
  55. * Function that maps parts of Redux state tree into component props.
  56. *
  57. * @param {Object} state - Redux state.
  58. * @returns {Object}
  59. */
  60. const mapStateToProps = (state: IReduxState) => {
  61. const localParticipant = getLocalParticipant(state);
  62. return {
  63. raisedHand: hasRaisedHand(localParticipant)
  64. };
  65. };
  66. export default translate(connect(mapStateToProps)(RaiseHandButton));