2018-08-24 18:12:12 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
2020-06-23 12:46:04 +00:00
|
|
|
import { isLocalParticipantModerator } from '../../base/participants';
|
2020-07-24 12:14:33 +00:00
|
|
|
import { AbstractButton, type AbstractButtonProps } from '../../base/toolbox/components';
|
2018-08-24 18:12:12 +00:00
|
|
|
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.
|
2018-09-06 20:18:14 +00:00
|
|
|
* @param {Object} ownProps - The properties explicitly passed to the component
|
|
|
|
* instance.
|
2018-08-24 18:12:12 +00:00
|
|
|
* @private
|
|
|
|
* @returns {{
|
2018-09-06 20:18:14 +00:00
|
|
|
* _requestingSubtitles: boolean,
|
|
|
|
* visible: boolean
|
2018-08-24 18:12:12 +00:00
|
|
|
* }}
|
|
|
|
*/
|
2018-09-06 20:18:14 +00:00
|
|
|
export function _abstractMapStateToProps(state: Object, ownProps: Object) {
|
2018-08-24 18:12:12 +00:00
|
|
|
const { _requestingSubtitles } = state['features/subtitles'];
|
2018-09-06 20:18:14 +00:00
|
|
|
const { transcribingEnabled } = state['features/base/config'];
|
2020-06-23 12:46:04 +00:00
|
|
|
const { visible = Boolean(transcribingEnabled && isLocalParticipantModerator(state)) } = ownProps;
|
2018-08-24 18:12:12 +00:00
|
|
|
|
|
|
|
return {
|
2018-09-06 20:18:14 +00:00
|
|
|
_requestingSubtitles,
|
|
|
|
visible
|
2018-08-24 18:12:12 +00:00
|
|
|
};
|
|
|
|
}
|