12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- // @flow
-
- import { createToolbarEvent, sendAnalytics } from '../../analytics';
- import { isLocalParticipantModerator } from '../../base/participants';
- import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
- import { toggleRequestingSubtitles } from '../actions';
-
- export type AbstractProps = AbstractButtonProps & {
-
- /**
- * Invoked to obtain translated strings.
- */
- t: Function,
-
- /**
- * Invoked to Dispatch an Action to the redux store.
- */
- dispatch: Function,
-
- /**
- * Whether the local participant is currently requesting subtitles.
- */
- _requestingSubtitles: Boolean
- };
-
- /**
- * The button component which starts/stops the transcription.
- */
- export class AbstractClosedCaptionButton
- extends AbstractButton<AbstractProps, *> {
- /**
- * Handles clicking / pressing the button.
- *
- * @override
- * @protected
- * @returns {void}
- */
- _handleClick() {
- const { _requestingSubtitles, dispatch } = this.props;
-
- sendAnalytics(createToolbarEvent('transcribing.ccButton',
- {
- 'requesting_subtitles': Boolean(_requestingSubtitles)
- }));
-
- dispatch(toggleRequestingSubtitles());
- }
-
- /**
- * Indicates whether this button is disabled or not.
- *
- * @override
- * @protected
- * @returns {boolean}
- */
- _isDisabled() {
- return false;
- }
-
- /**
- * Indicates whether this button is in toggled state or not.
- *
- * @override
- * @protected
- * @returns {boolean}
- */
- _isToggled() {
- return this.props._requestingSubtitles;
- }
- }
-
- /**
- * Maps (parts of) the redux state to the associated props for the
- * {@code AbstractClosedCaptionButton} component.
- *
- * @param {Object} state - The redux state.
- * @param {Object} ownProps - The properties explicitly passed to the component
- * instance.
- * @private
- * @returns {{
- * _requestingSubtitles: boolean,
- * visible: boolean
- * }}
- */
- export function _abstractMapStateToProps(state: Object, ownProps: Object) {
- const { _requestingSubtitles } = state['features/subtitles'];
- const { transcribingEnabled } = state['features/base/config'];
- const { visible = Boolean(transcribingEnabled && isLocalParticipantModerator(state)) } = ownProps;
-
- return {
- _requestingSubtitles,
- visible
- };
- }
|