dispatch/client/src/js/components/ChatTitle.js

57 lines
1.6 KiB
JavaScript
Raw Normal View History

import React, { PureComponent } from 'react';
2015-12-28 23:34:32 +00:00
import { List } from 'immutable';
import Navicon from '../components/Navicon';
import { linkify } from '../util';
2015-12-28 23:34:32 +00:00
export default class ChatTitle extends PureComponent {
2015-12-28 23:34:32 +00:00
handleLeaveClick = () => {
2016-01-05 18:29:22 +00:00
const { tab, disconnect, part, closePrivateChat } = this.props;
2015-12-28 23:34:32 +00:00
if (tab.isChannel()) {
part([tab.name], tab.server);
} else if (tab.name) {
closePrivateChat(tab.server, tab.name);
2015-12-28 23:34:32 +00:00
} else {
disconnect(tab.server);
}
};
2015-12-28 23:34:32 +00:00
render() {
2016-01-11 22:31:06 +00:00
const { title, tab, channel, toggleSearch, toggleUserList } = this.props;
2017-02-16 02:55:50 +00:00
let topic = channel.get('topic');
topic = topic ? linkify(topic) : null;
2015-12-28 23:34:32 +00:00
let leaveTitle;
if (tab.isChannel()) {
2015-12-28 23:34:32 +00:00
leaveTitle = 'Leave';
} else if (tab.name) {
2015-12-28 23:34:32 +00:00
leaveTitle = 'Close';
} else {
leaveTitle = 'Disconnect';
}
return (
<div>
<div className="chat-title-bar">
<Navicon />
<span className="chat-title">{title}</span>
<div className="chat-topic-wrap">
<span className="chat-topic">{topic}</span>
2015-12-28 23:34:32 +00:00
</div>
<i className="icon-search" title="Search" onClick={toggleSearch} />
<i
className="icon-logout button-leave"
title={leaveTitle}
onClick={this.handleLeaveClick}
/>
2016-01-11 22:31:06 +00:00
<i className="icon-user button-userlist" onClick={toggleUserList} />
2015-12-28 23:34:32 +00:00
</div>
<div className="userlist-bar">
<i className="icon-user" />
<span className="chat-usercount">{channel.get('users', List()).size || null}</span>
</div>
</div>
);
}
}