import React, { Component, PropTypes } from 'react' import MapInfoBox from './MapInfoBox' import MapChat from './MapChat' import TopicCard from '../TopicCard' class MapView extends Component { static propTypes = { mapId: PropTypes.string, map: PropTypes.object, mapIsStarred: PropTypes.bool, currentUser: PropTypes.object, endActiveMap: PropTypes.func, launchNewMap: PropTypes.func } constructor(props) { super(props) this.state = {} } componentDidMount() { window && window.addEventListener('resize', this.resize) this.resize() } componentDidUpdate(prevProps) { const oldMapId = prevProps.mapId const { mapId, endActiveMap, launchNewMap } = this.props if (!oldMapId && mapId) launchNewMap(mapId) else if (oldMapId && mapId && oldMapId !== mapId) { endActiveMap() launchNewMap(mapId) } else if (oldMapId && !mapId) endActiveMap() } componentWillUnmount() { window && window.removeEventListener('resize', this.resize) } resize = () => { } render = () => { const { mapIsStarred } = this.props const starclassName = mapIsStarred ? 'starred' : '' const tooltip = mapIsStarred ? 'Star' : 'Unstar' return