fix(subtitles) keep subtitles state when recording

This commit is contained in:
Saúl Ibarra Corretgé
2024-02-27 14:57:57 +01:00
committed by Hristo Terezov
parent 05aa48774a
commit a6f6b3a2d2
3 changed files with 57 additions and 29 deletions

View File

@@ -32,6 +32,11 @@ export interface IProps extends WithTranslation {
*/
_conference?: IJitsiConference;
/**
* Whether subtitles should be displayed or not.
*/
_displaySubtitles?: boolean;
/**
* Whether to show file recordings service, even if integrations
* are enabled.
@@ -69,6 +74,11 @@ export interface IProps extends WithTranslation {
*/
_screenshotCaptureEnabled: boolean;
/**
* The selected language for subtitles.
*/
_subtitlesLanguage: string | null;
/**
* The dropbox access token.
*/
@@ -336,8 +346,10 @@ class AbstractStartRecordingDialog extends Component<IProps, IState> {
const {
_appKey,
_conference,
_displaySubtitles,
_isDropboxEnabled,
_rToken,
_subtitlesLanguage,
_token,
dispatch
} = this.props;
@@ -399,7 +411,7 @@ class AbstractStartRecordingDialog extends Component<IProps, IState> {
if (this.state.selectedRecordingService === RECORDING_TYPES.JITSI_REC_SERVICE
&& this.state.shouldRecordTranscription) {
dispatch(setRequestingSubtitles(true, false, null));
dispatch(setRequestingSubtitles(true, _displaySubtitles, _subtitlesLanguage));
}
_conference?.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, {
@@ -434,17 +446,7 @@ class AbstractStartRecordingDialog extends Component<IProps, IState> {
* @param {Object} state - The Redux state.
* @param {any} _ownProps - Component's own props.
* @private
* @returns {{
* _appKey: string,
* _autoTranscribeOnRecord: boolean,
* _conference: JitsiConference,
* _fileRecordingsServiceEnabled: boolean,
* _fileRecordingsServiceSharingEnabled: boolean,
* _isDropboxEnabled: boolean,
* _rToken:string,
* _tokenExpireDate: number,
* _token: string
* }}
* @returns {IProps}
*/
export function mapStateToProps(state: IReduxState, _ownProps: any) {
const {
@@ -452,16 +454,22 @@ export function mapStateToProps(state: IReduxState, _ownProps: any) {
dropbox = { appKey: undefined },
localRecording
} = state['features/base/config'];
const {
_displaySubtitles,
_language: _subtitlesLanguage
} = state['features/subtitles'];
return {
_appKey: dropbox.appKey ?? '',
_autoTranscribeOnRecord: shouldAutoTranscribeOnRecord(state),
_conference: state['features/base/conference'].conference,
_displaySubtitles,
_fileRecordingsServiceEnabled: recordingService?.enabled ?? false,
_fileRecordingsServiceSharingEnabled: isRecordingSharingEnabled(state),
_isDropboxEnabled: isDropboxEnabled(state),
_localRecordingEnabled: !localRecording?.disable,
_rToken: state['features/dropbox'].rToken ?? '',
_subtitlesLanguage,
_tokenExpireDate: state['features/dropbox'].expireDate,
_token: state['features/dropbox'].token ?? ''
};

View File

@@ -26,6 +26,11 @@ export interface IProps extends WithTranslation {
*/
_conference?: IJitsiConference;
/**
* Whether subtitles should be displayed or not.
*/
_displaySubtitles?: boolean;
/**
* The redux representation of the recording session to be stopped.
*/
@@ -36,6 +41,11 @@ export interface IProps extends WithTranslation {
*/
_localRecording: boolean;
/**
* The selected language for subtitles.
*/
_subtitlesLanguage: string | null;
/**
* The redux dispatch function.
*/
@@ -77,22 +87,28 @@ export default class AbstractStopRecordingDialog<P extends IProps>
_onSubmit() {
sendAnalytics(createRecordingDialogEvent('stop', 'confirm.button'));
if (this.props._localRecording) {
this.props.dispatch(stopLocalVideoRecording());
if (this.props.localRecordingVideoStop) {
this.props.dispatch(setVideoMuted(true));
}
} else {
const { _fileRecordingSession } = this.props;
const {
_conference,
_displaySubtitles,
_fileRecordingSession,
_localRecording,
_subtitlesLanguage,
dispatch,
localRecordingVideoStop
} = this.props;
if (_fileRecordingSession) {
this.props._conference?.stopRecording(_fileRecordingSession.id);
this._toggleScreenshotCapture();
if (_localRecording) {
dispatch(stopLocalVideoRecording());
if (localRecordingVideoStop) {
dispatch(setVideoMuted(true));
}
} else if (_fileRecordingSession) {
_conference?.stopRecording(_fileRecordingSession.id);
this._toggleScreenshotCapture();
}
// TODO: this should be an action in transcribing. -saghul
this.props.dispatch(setRequestingSubtitles(false, false, null));
this.props.dispatch(setRequestingSubtitles(Boolean(_displaySubtitles), _displaySubtitles, _subtitlesLanguage));
this.props._conference?.getMetadataHandler().setMetadata(RECORDING_METADATA_ID, {
isTranscribingEnabled: false
@@ -117,16 +133,20 @@ export default class AbstractStopRecordingDialog<P extends IProps>
*
* @param {Object} state - The Redux state.
* @private
* @returns {{
* _conference: JitsiConference,
* _fileRecordingSession: Object
* }}
* @returns {IProps}
*/
export function _mapStateToProps(state: IReduxState) {
const {
_displaySubtitles,
_language: _subtitlesLanguage
} = state['features/subtitles'];
return {
_conference: state['features/base/conference'].conference,
_displaySubtitles,
_fileRecordingSession:
getActiveSession(state, JitsiRecordingConstants.mode.FILE),
_localRecording: LocalRecordingManager.isRecordingLocally()
_localRecording: LocalRecordingManager.isRecordingLocally(),
_subtitlesLanguage
};
}

View File

@@ -9,7 +9,7 @@ import {
* Default State for 'features/transcription' feature.
*/
const defaultState = {
_displaySubtitles: true,
_displaySubtitles: false,
_transcriptMessages: new Map(),
_requestingSubtitles: false,
_language: null