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.

ToggleSelfViewButton.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // @flow
  2. import { translate } from '../../../base/i18n';
  3. import { IconAudioOnlyOff } from '../../../base/icons';
  4. import { connect } from '../../../base/redux';
  5. import { updateSettings } from '../../../base/settings';
  6. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  7. /**
  8. * The type of the React {@code Component} props of {@link ToggleSelfViewButton}.
  9. */
  10. type Props = AbstractButtonProps & {
  11. /**
  12. * Whether the self view is disabled or not.
  13. */
  14. _disableSelfView: boolean,
  15. /**
  16. * The redux {@code dispatch} function.
  17. */
  18. dispatch: Function
  19. };
  20. /**
  21. * An implementation of a button for toggling the self view.
  22. */
  23. class ToggleSelfViewButton extends AbstractButton<Props, *> {
  24. accessibilityLabel = 'toolbar.accessibilityLabel.selfView';
  25. icon = IconAudioOnlyOff;
  26. label = 'videothumbnail.hideSelfView';
  27. toggledLabel = 'videothumbnail.showSelfView';
  28. /**
  29. * Handles clicking / pressing the button.
  30. *
  31. * @override
  32. * @protected
  33. * @returns {void}
  34. */
  35. _handleClick() {
  36. const { _disableSelfView, dispatch } = this.props;
  37. dispatch(updateSettings({
  38. disableSelfView: !_disableSelfView
  39. }));
  40. }
  41. /**
  42. * Indicates whether this button is in toggled state or not.
  43. *
  44. * @override
  45. * @protected
  46. * @returns {boolean}
  47. */
  48. _isToggled() {
  49. return this.props._disableSelfView;
  50. }
  51. }
  52. /**
  53. * Maps (parts of) the redux state to the associated props for the
  54. * {@code ToggleSelfViewButton} component.
  55. *
  56. * @param {Object} state - The Redux state.
  57. * @private
  58. * @returns {{
  59. * _disableSelfView: boolean
  60. * }}
  61. */
  62. function _mapStateToProps(state): Object {
  63. const { disableSelfView } = state['features/base/settings'];
  64. return {
  65. _disableSelfView: Boolean(disableSelfView)
  66. };
  67. }
  68. export default translate(connect(_mapStateToProps)(ToggleSelfViewButton));