import React, { useState, useEffect } from 'react'; import cn from 'classnames'; import Counter from 'App/components/shared/SessionItem/Counter'; import { useDraggable } from '@neodrag/react'; import type { LocalStream } from 'Player'; import { PlayerContext } from 'App/components/Session/playerContext'; import ChatControls from '../ChatControls/ChatControls'; import stl from './chatWindow.module.css'; import VideoContainer from '../components/VideoContainer'; import { useTranslation } from 'react-i18next'; export interface Props { incomeStream: { stream: MediaStream; isAgent: boolean }[] | null; localStream: LocalStream | null; userId: string; isPrestart?: boolean; endCall: () => void; } function ChatWindow({ userId, incomeStream, localStream, endCall, isPrestart, }: Props) { const { t } = useTranslation(); const dragRef = React.useRef(null); useDraggable(dragRef, { bounds: 'body', defaultPosition: { x: 50, y: 200 } }) const { player } = React.useContext(PlayerContext); const { toggleVideoLocalStream } = player.assistManager; const [localVideoEnabled, setLocalVideoEnabled] = useState(false); const [anyRemoteEnabled, setRemoteEnabled] = useState(false); const onlyLocalEnabled = localVideoEnabled && !anyRemoteEnabled; useEffect(() => { toggleVideoLocalStream(localVideoEnabled); }, [localVideoEnabled]); return (
{t('Call with')}  {userId || t('Anonymous User')}
{incomeStream && incomeStream.length > 2 ? t(' (+ other agents in the call)') : ''}
{incomeStream ? ( incomeStream.map((stream) => ( )) ) : (
{t('Error obtaining incoming streams')}
)}
); } export default ChatWindow;