import React, { PropTypes, Component } from 'react' import Unread from './Unread' import Participant from './Participant' import Message from './Message' class MapChat extends Component { constructor(props) { super(props) this.state = { unreadMessages: 0, open: false, messageText: '', alertSound: true, // whether to play sounds on arrival of new messages or not cursorsShowing: true, videosShowing: true } } reset = () => { this.setState({ unreadMessages: 0, open: false, messageText: '', alertSound: true, // whether to play sounds on arrival of new messages or not cursorsShowing: true, videosShowing: true }) } close = () => { this.setState({open: false}) this.props.onClose() } open = () => { this.setState({open: true, unreadMessages: 0}) this.props.onOpen() } newMessage = () => { if (!this.state.open) this.setState({unreadMessages: this.state.unreadMessages + 1}) } toggleDrawer = () => { if (this.state.open) this.close() else if (!this.state.open) this.open() } toggleAlertSound = () => { this.setState({alertSound: !this.state.alertSound}) this.props.soundToggleClick() } toggleCursorsShowing = () => { this.setState({cursorsShowing: !this.state.cursorsShowing}) this.props.cursorToggleClick() } toggleVideosShowing = () => { this.setState({videosShowing: !this.state.videosShowing}) this.props.videoToggleClick() } handleChange = key => e => { this.setState({ [key]: e.target.value }) } handleTextareaKeyUp = e => { if (e.which === 13) { e.preventDefault() const text = this.state.messageText this.props.handleInputMessage(text) this.setState({ messageText: '' }) } } render = () => { const rightOffset = this.state.open ? '0' : '-300px' const { conversationLive, isParticipating, participants, messages } = this.props const { videosShowing, cursorsShowing, alertSound, unreadMessages } = this.state return (