import classnames from 'classnames' import map from 'lodash/map' import React from 'react' import Peer from 'simple-peer' import { Message } from '../actions/ChatActions' import { dismissNotification, Notification } from '../actions/NotifyActions' import { TextMessage } from '../actions/PeerActions' import { AddStreamPayload, removeStream } from '../actions/StreamActions' import * as constants from '../constants' import Chat from './Chat' import { Media } from './Media' import Notifications from './Notifications' import { Side } from './Side' import Toolbar from './Toolbar' import Video from './Video' import { getDesktopStream } from '../actions/MediaActions' export interface AppProps { active: string | null dismissNotification: typeof dismissNotification init: () => void notifications: Record messages: Message[] messagesCount: number peers: Record play: () => void sendMessage: (message: TextMessage) => void streams: Record getDesktopStream: typeof getDesktopStream removeStream: typeof removeStream onSendFile: (file: File) => void toggleActive: (userId: string) => void } export interface AppState { videos: Record chatVisible: boolean } const localStreams: string[] = [constants.ME, constants.ME_DESKTOP] export default class App extends React.PureComponent { state: AppState = { videos: {}, chatVisible: false, } handleShowChat = () => { this.setState({ chatVisible: true, }) } handleHideChat = () => { this.setState({ chatVisible: false, }) } handleToggleChat = () => { return this.state.chatVisible ? this.handleHideChat() : this.handleShowChat() } componentDidMount () { const { init } = this.props init() } onHangup = () => { this.props.removeStream(constants.ME) this.props.removeStream(constants.ME_DESKTOP) } render () { const { active, dismissNotification, notifications, messages, messagesCount, onSendFile, play, peers, sendMessage, toggleActive, streams, } = this.props const { videos } = this.state const chatVisibleClassName = classnames({ 'chat-visible': this.state.chatVisible, }) return (
{localStreams.map(userId => (
) } }