import React from 'react'; import { Text, View, ViewStyle } from 'react-native'; import { useSelector } from 'react-redux'; import { IReduxState } from '../../../app/types'; import { getParticipantDisplayName } from '../../../base/participants/functions'; import { ISubtitle } from '../../../subtitles/types'; import { closedCaptionsStyles } from './styles'; interface IProps extends ISubtitle { showDisplayName: boolean; } export default function SubtitleMessage({ participantId, text, timestamp, interim, showDisplayName }: IProps) { const participantName = useSelector((state: IReduxState) => getParticipantDisplayName(state, participantId)); const containerStyle: ViewStyle[] = [ closedCaptionsStyles.subtitleMessageContainer as ViewStyle ]; if (interim) { containerStyle.push(closedCaptionsStyles.subtitleMessageInterim as ViewStyle); } return ( { showDisplayName && ( { participantName } ) } { text } { new Date(timestamp).toLocaleTimeString() } ); }