Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(subtitles): toggle subtitles directly when translation is disabled

damencho8d732e18a091
diff --git a/react/features/subtitles/components/AbstractClosedCaptionButton.tsx b/react/features/subtitles/components/AbstractClosedCaptionButton.tsx
index d17f9ae6d9..59354c85ce 100644
--- a/react/features/subtitles/components/AbstractClosedCaptionButton.tsx
+++ b/react/features/subtitles/components/AbstractClosedCaptionButton.tsx
@@ -19,6 +19,11 @@ export interface IAbstractProps extends AbstractButtonProps {
*/
_isCCTabEnabled: boolean;
+ /**
+ * Whether subtitle translation (language selection) is enabled.
+ */
+ _isTranslationEnabled?: boolean;
+
_language: string | null;
/**
diff --git a/react/features/subtitles/components/web/ClosedCaptionButton.tsx b/react/features/subtitles/components/web/ClosedCaptionButton.tsx
index b2e8aa292a..0d7dfe940a 100644
--- a/react/features/subtitles/components/web/ClosedCaptionButton.tsx
+++ b/react/features/subtitles/components/web/ClosedCaptionButton.tsx
@@ -4,8 +4,9 @@ import { IReduxState } from '../../../app/types';
import { translate } from '../../../base/i18n/functions';
import { IconSubtitles } from '../../../base/icons/svg';
import { openCCPanel } from '../../../chat/actions.any';
+import { setRequestingSubtitles } from '../../actions.any';
import { toggleLanguageSelectorDialog } from '../../actions.web';
-import { canStartSubtitles, isCCTabEnabled } from '../../functions.any';
+import { canStartSubtitles, isCCTabEnabled, isTranslationEnabled } from '../../functions.any';
import {
AbstractClosedCaptionButton,
IAbstractProps,
@@ -63,12 +64,16 @@ class ClosedCaptionButton
* @returns {void}
*/
override _handleClickOpenLanguageSelector() {
- const { dispatch, _isCCTabEnabled } = this.props;
+ const { dispatch, _isCCTabEnabled, _isTranslationEnabled, _requestingSubtitles } = this.props;
if (_isCCTabEnabled) {
dispatch(openCCPanel());
- } else {
+ } else if (_isTranslationEnabled) {
dispatch(toggleLanguageSelectorDialog());
+ } else {
+ // Translation is disabled, so the language selector dialog has nothing to display (it renders nothing).
+ // Toggle the subtitles in the source language directly instead of opening an empty dialog.
+ dispatch(setRequestingSubtitles(!_requestingSubtitles, !_requestingSubtitles, null));
}
}
}
@@ -83,10 +88,13 @@ class ClosedCaptionButton
function mapStateToProps(state: IReduxState, ownProps: IAbstractProps) {
const { visible = canStartSubtitles(state) || isCCTabEnabled(state) } = ownProps;
- return _abstractMapStateToProps(state, {
- ...ownProps,
- visible
- });
+ return {
+ ..._abstractMapStateToProps(state, {
+ ...ownProps,
+ visible
+ }),
+ _isTranslationEnabled: isTranslationEnabled(state)
+ };
}
export default translate(connect(mapStateToProps)(ClosedCaptionButton));