From 955b24be9d9f4a525cf7fe3a541846dc92861417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Wed, 1 Apr 2020 13:08:02 +0200 Subject: [PATCH] rn,cc: add feature-flag to disable close captions --- react/features/base/flags/constants.js | 6 +++++ .../components/ClosedCaptionButton.native.js | 24 +++++++++++++++++-- .../components/ClosedCaptionButton.web.js | 3 +-- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/react/features/base/flags/constants.js b/react/features/base/flags/constants.js index 41187a07b..e5d122e77 100644 --- a/react/features/base/flags/constants.js +++ b/react/features/base/flags/constants.js @@ -13,6 +13,12 @@ export const CALENDAR_ENABLED = 'calendar.enabled'; */ export const CALL_INTEGRATION_ENABLED = 'call-integration.enabled'; +/** + * Flag indicating if chat should be enabled. + * Default: enabled (true). + */ +export const CLOSE_CAPTIONS_ENABLED = 'close-captions.enabled'; + /** * Flag indicating if chat should be enabled. * Default: enabled (true). diff --git a/react/features/subtitles/components/ClosedCaptionButton.native.js b/react/features/subtitles/components/ClosedCaptionButton.native.js index 7be1d19dc..b0887fe22 100644 --- a/react/features/subtitles/components/ClosedCaptionButton.native.js +++ b/react/features/subtitles/components/ClosedCaptionButton.native.js @@ -1,5 +1,6 @@ // @flow +import { getFeatureFlag, CLOSE_CAPTIONS_ENABLED } from '../../base/flags'; import { translate } from '../../base/i18n'; import { IconClosedCaption } from '../../base/icons'; import { connect } from '../../base/redux'; @@ -20,5 +21,24 @@ class ClosedCaptionButton toggledLabel = 'transcribing.stop'; } -export default translate(connect(_abstractMapStateToProps)( - ClosedCaptionButton)); +/** + * Maps (parts of) the redux state to the associated props for this component. + * + * @param {Object} state - The redux state. + * @param {Object} ownProps - The properties explicitly passed to the component + * instance. + * @private + * @returns {Props} + */ +export function mapStateToProps(state: Object, ownProps: Object) { + const { transcribingEnabled } = state['features/base/config']; + const enabled = getFeatureFlag(state, CLOSE_CAPTIONS_ENABLED, true) && transcribingEnabled; + const { visible = enabled } = ownProps; + + return { + ..._abstractMapStateToProps(state, ownProps), + visible + }; +} + +export default translate(connect(mapStateToProps)(ClosedCaptionButton)); diff --git a/react/features/subtitles/components/ClosedCaptionButton.web.js b/react/features/subtitles/components/ClosedCaptionButton.web.js index 482d548aa..9e761837f 100644 --- a/react/features/subtitles/components/ClosedCaptionButton.web.js +++ b/react/features/subtitles/components/ClosedCaptionButton.web.js @@ -22,5 +22,4 @@ class ClosedCaptionButton toggledLabel = 'toolbar.stopSubtitles'; } -export default translate(connect(_abstractMapStateToProps)( - ClosedCaptionButton)); +export default translate(connect(_abstractMapStateToProps)(ClosedCaptionButton));