2018-08-24 18:12:12 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { createToolbarEvent, sendAnalytics } from '../../analytics';
|
2022-10-04 13:02:49 +00:00
|
|
|
import { MEET_FEATURES } from '../../base/jwt/constants';
|
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';
|
2021-06-25 13:28:54 +00:00
|
|
|
import { maybeShowPremiumFeatureDialog } from '../../jaas/actions';
|
2018-08-24 18:12:12 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2022-08-31 15:57:31 +00:00
|
|
|
_requestingSubtitles: Boolean,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selected language for subtitle.
|
|
|
|
*/
|
|
|
|
_subtitles: String
|
2018-08-24 18:12:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The button component which starts/stops the transcription.
|
|
|
|
*/
|
|
|
|
export class AbstractClosedCaptionButton
|
|
|
|
extends AbstractButton<AbstractProps, *> {
|
2022-08-31 15:57:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to be implemented by subclasses, which should be used
|
|
|
|
* to handle the closed caption button being clicked / pressed.
|
|
|
|
*
|
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
_handleClickOpenLanguageSelector() {
|
|
|
|
// To be implemented by subclass.
|
|
|
|
}
|
|
|
|
|
2018-08-24 18:12:12 +00:00
|
|
|
/**
|
|
|
|
* Handles clicking / pressing the button.
|
|
|
|
*
|
|
|
|
* @override
|
|
|
|
* @protected
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-06-25 13:28:54 +00:00
|
|
|
async _handleClick() {
|
2022-01-04 11:21:00 +00:00
|
|
|
const { _requestingSubtitles, dispatch } = this.props;
|
2018-08-24 18:12:12 +00:00
|
|
|
|
|
|
|
sendAnalytics(createToolbarEvent('transcribing.ccButton',
|
|
|
|
{
|
|
|
|
'requesting_subtitles': Boolean(_requestingSubtitles)
|
|
|
|
}));
|
|
|
|
|
2022-10-04 13:02:49 +00:00
|
|
|
const dialogShown = await dispatch(maybeShowPremiumFeatureDialog(MEET_FEATURES.RECORDING));
|
2021-06-25 13:28:54 +00:00
|
|
|
|
|
|
|
if (!dialogShown) {
|
2022-08-31 15:57:31 +00:00
|
|
|
this._handleClickOpenLanguageSelector();
|
2021-06-25 13:28:54 +00:00
|
|
|
}
|
2018-08-24 18:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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,
|
2022-08-31 15:57:31 +00:00
|
|
|
* _language: string,
|
2018-09-06 20:18:14 +00:00
|
|
|
* 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) {
|
2022-08-31 15:57:31 +00:00
|
|
|
const { _requestingSubtitles, _language } = state['features/subtitles'];
|
2022-06-28 11:11:26 +00:00
|
|
|
const { transcription } = state['features/base/config'];
|
2020-11-05 19:11:38 +00:00
|
|
|
const { isTranscribing } = state['features/transcribing'];
|
|
|
|
|
|
|
|
// if the participant is moderator, it can enable transcriptions and if
|
|
|
|
// transcriptions are already started for the meeting, guests can just show them
|
2022-06-28 11:11:26 +00:00
|
|
|
const { visible = Boolean(transcription?.enabled
|
2020-11-05 19:11:38 +00:00
|
|
|
&& (isLocalParticipantModerator(state) || isTranscribing)) } = ownProps;
|
2018-08-24 18:12:12 +00:00
|
|
|
|
|
|
|
return {
|
2018-09-06 20:18:14 +00:00
|
|
|
_requestingSubtitles,
|
2022-08-31 15:57:31 +00:00
|
|
|
_language,
|
2018-09-06 20:18:14 +00:00
|
|
|
visible
|
2018-08-24 18:12:12 +00:00
|
|
|
};
|
|
|
|
}
|