import React, { PureComponent } from 'react'; import { List } from 'immutable'; import Navicon from '../components/Navicon'; import { linkify } from '../util'; export default class ChatTitle extends PureComponent { handleLeaveClick = () => { const { tab, disconnect, part, closePrivateChat } = this.props; if (tab.isChannel()) { part([tab.name], tab.server); } else if (tab.name) { closePrivateChat(tab.server, tab.name); } else { disconnect(tab.server); } }; render() { const { title, tab, channel, toggleSearch, toggleUserList } = this.props; let topic = channel.get('topic'); topic = topic ? linkify(topic) : null; let leaveTitle; if (tab.isChannel()) { leaveTitle = 'Leave'; } else if (tab.name) { leaveTitle = 'Close'; } else { leaveTitle = 'Disconnect'; } return (
{title}
{topic}
{channel.get('users', List()).size || null}
); } }