2018-08-23 19:57:12 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
2019-03-21 16:38:29 +00:00
|
|
|
|
2021-07-20 08:37:52 +00:00
|
|
|
import { getLocalParticipant } from '../../base/participants';
|
2019-03-21 16:38:29 +00:00
|
|
|
import { connect } from '../../base/redux';
|
2021-07-20 08:37:52 +00:00
|
|
|
import { getLargeVideoParticipant } from '../../large-video/functions';
|
|
|
|
import { isLayoutTileView } from '../../video-layout';
|
2018-08-23 19:57:12 +00:00
|
|
|
|
|
|
|
import {
|
|
|
|
AbstractCaptions,
|
2022-09-27 07:10:28 +00:00
|
|
|
type AbstractCaptionsProps,
|
|
|
|
_abstractMapStateToProps
|
2018-08-23 19:57:12 +00:00
|
|
|
} from './AbstractCaptions';
|
|
|
|
|
2021-03-29 07:02:26 +00:00
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the subtitles container is lifted above the invite box.
|
|
|
|
*/
|
|
|
|
_isLifted: boolean
|
|
|
|
} & AbstractCaptionsProps;
|
|
|
|
|
2018-08-23 19:57:12 +00:00
|
|
|
/**
|
|
|
|
* React {@code Component} which can display speech-to-text results from
|
|
|
|
* Jigasi as subtitles.
|
|
|
|
*/
|
|
|
|
class Captions
|
|
|
|
extends AbstractCaptions<Props> {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the transcription text.
|
|
|
|
*
|
|
|
|
* @param {string} id - The ID of the transcript message from which the
|
|
|
|
* {@code text} has been created.
|
|
|
|
* @param {string} text - Subtitles text formatted with the participant's
|
|
|
|
* name.
|
|
|
|
* @protected
|
|
|
|
* @returns {React$Element} - The React element which displays the text.
|
|
|
|
*/
|
|
|
|
_renderParagraph(id: string, text: string): React$Element<*> {
|
|
|
|
return (
|
|
|
|
<p key = { id }>
|
|
|
|
<span>{ text }</span>
|
|
|
|
</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Renders the subtitles container.
|
|
|
|
*
|
|
|
|
* @param {Array<React$Element>} paragraphs - An array of elements created
|
|
|
|
* for each subtitle using the {@link _renderParagraph} method.
|
|
|
|
* @protected
|
|
|
|
* @returns {React$Element} - The subtitles container.
|
|
|
|
*/
|
|
|
|
_renderSubtitlesContainer(
|
|
|
|
paragraphs: Array<React$Element<*>>): React$Element<*> {
|
2021-03-29 07:02:26 +00:00
|
|
|
|
|
|
|
const className = this.props._isLifted ? 'transcription-subtitles lifted' : 'transcription-subtitles';
|
|
|
|
|
2018-08-23 19:57:12 +00:00
|
|
|
return (
|
2021-03-29 07:02:26 +00:00
|
|
|
<div className = { className } >
|
2018-08-23 19:57:12 +00:00
|
|
|
{ paragraphs }
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-29 07:02:26 +00:00
|
|
|
/**
|
|
|
|
* Maps (parts of) the redux state to the associated {@code }'s
|
|
|
|
* props.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The redux state.
|
|
|
|
* @private
|
|
|
|
* @returns {Object}
|
|
|
|
*/
|
|
|
|
function mapStateToProps(state) {
|
2021-07-20 08:37:52 +00:00
|
|
|
const isTileView = isLayoutTileView(state);
|
|
|
|
const largeVideoParticipant = getLargeVideoParticipant(state);
|
|
|
|
const localParticipant = getLocalParticipant(state);
|
|
|
|
|
2021-03-29 07:02:26 +00:00
|
|
|
return {
|
|
|
|
..._abstractMapStateToProps(state),
|
2021-07-20 08:37:52 +00:00
|
|
|
_isLifted: largeVideoParticipant && largeVideoParticipant?.id !== localParticipant?.id && !isTileView
|
2021-03-29 07:02:26 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps)(Captions);
|