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.ts 1.9KB

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