//@ts-nocheck import React, { useState, FC, useEffect } from 'react' import VideoContainer from '../components/VideoContainer' import cn from 'classnames' import Counter from 'App/components/shared/SessionItem/Counter' import stl from './chatWindow.module.css' import ChatControls from '../ChatControls/ChatControls' import Draggable from 'react-draggable'; import type { LocalStream } from 'Player/MessageDistributor/managers/LocalStream'; export interface Props { incomeStream: MediaStream | null, localStream: LocalStream | null, userId: String, endCall: () => void } const ChatWindow: FC = function ChatWindow({ userId, incomeStream, localStream, endCall }) { const [localVideoEnabled, setLocalVideoEnabled] = useState(false) const [remoteVideoEnabled, setRemoteVideoEnabled] = useState(false) useEffect(() => { if (!incomeStream) { return } const iid = setInterval(() => { const settings = incomeStream.getVideoTracks()[0]?.getSettings() const isDummyVideoTrack = !!settings ? (settings.width === 2 || settings.frameRate === 0) : true const shouldBeEnabled = !isDummyVideoTrack if (shouldBeEnabled !== localVideoEnabled) { setRemoteVideoEnabled(shouldBeEnabled) } }, 1000) return () => clearInterval(iid) }, [ incomeStream, localVideoEnabled ]) const minimize = !localVideoEnabled && !remoteVideoEnabled return (
Talking to {userId ? userId : 'Anonymous User'}
) } export default ChatWindow