Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

AbstractClosedCaptionButton.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // @flow
  2. import { createToolbarEvent, sendAnalytics } from '../../analytics';
  3. import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox';
  4. import { toggleRequestingSubtitles } from '../actions';
  5. export type AbstractProps = AbstractButtonProps & {
  6. /**
  7. * Invoked to obtain translated strings.
  8. */
  9. t: Function,
  10. /**
  11. * Invoked to Dispatch an Action to the redux store.
  12. */
  13. dispatch: Function,
  14. /**
  15. * Whether the local participant is currently requesting subtitles.
  16. */
  17. _requestingSubtitles: Boolean
  18. };
  19. /**
  20. * The button component which starts/stops the transcription.
  21. */
  22. export class AbstractClosedCaptionButton
  23. extends AbstractButton<AbstractProps, *> {
  24. /**
  25. * Handles clicking / pressing the button.
  26. *
  27. * @override
  28. * @protected
  29. * @returns {void}
  30. */
  31. _handleClick() {
  32. const { _requestingSubtitles, dispatch } = this.props;
  33. sendAnalytics(createToolbarEvent('transcribing.ccButton',
  34. {
  35. 'requesting_subtitles': Boolean(_requestingSubtitles)
  36. }));
  37. dispatch(toggleRequestingSubtitles());
  38. }
  39. /**
  40. * Indicates whether this button is disabled or not.
  41. *
  42. * @override
  43. * @protected
  44. * @returns {boolean}
  45. */
  46. _isDisabled() {
  47. return false;
  48. }
  49. /**
  50. * Indicates whether this button is in toggled state or not.
  51. *
  52. * @override
  53. * @protected
  54. * @returns {boolean}
  55. */
  56. _isToggled() {
  57. return this.props._requestingSubtitles;
  58. }
  59. }
  60. /**
  61. * Maps (parts of) the redux state to the associated props for the
  62. * {@code AbstractClosedCaptionButton} component.
  63. *
  64. * @param {Object} state - The redux state.
  65. * @param {Object} ownProps - The properties explicitly passed to the component
  66. * instance.
  67. * @private
  68. * @returns {{
  69. * _requestingSubtitles: boolean,
  70. * visible: boolean
  71. * }}
  72. */
  73. export function _abstractMapStateToProps(state: Object, ownProps: Object) {
  74. const { _requestingSubtitles } = state['features/subtitles'];
  75. const { transcribingEnabled } = state['features/base/config'];
  76. const { visible = Boolean(transcribingEnabled) } = ownProps;
  77. return {
  78. _requestingSubtitles,
  79. visible
  80. };
  81. }