import React, { PureComponent } from 'react'; import classnames from 'classnames'; import get from 'lodash/get'; import Button from 'components/ui/Button'; import TabListItem from 'containers/TabListItem'; import { count } from 'utils'; export default class TabList extends PureComponent { handleTabClick = (server, target) => this.props.select(server, target); handleConnectClick = () => this.props.push('/connect'); handleSettingsClick = () => this.props.push('/settings'); render() { const { tab, channels, servers, privateChats, showTabList, openModal } = this.props; const tabs = []; const className = classnames('tablist', { 'off-canvas': showTabList }); channels.forEach(server => { const { address } = server; const srv = servers[address]; tabs.push( ); const chanCount = count(server.channels, c => c.joined); const chanLimit = get(srv.features, ['CHANLIMIT', '#'], 0) || srv.features.MAXCHANNELS; let chanLabel; if (chanLimit > 0) { chanLabel = ( {chanCount}/{chanLimit} ); } else if (chanCount > 0) { chanLabel = {chanCount}; } tabs.push(
openModal('channel', { server: address })} > CHANNELS {chanLabel}
); server.channels.forEach(({ name, joined }) => tabs.push( ) ); if (privateChats[address] && privateChats[address].length > 0) { tabs.push(
DIRECT MESSAGES{' '} {privateChats[address].length} {/* */}
); privateChats[address].forEach(nick => tabs.push( ) ); } }); return (
{tabs}
); } }