2017-02-17 00:46:39 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2015-12-28 23:34:32 +00:00
|
|
|
import { List } from 'immutable';
|
|
|
|
import Navicon from '../components/Navicon';
|
2016-02-17 00:49:27 +00:00
|
|
|
import { linkify } from '../util';
|
2015-12-28 23:34:32 +00:00
|
|
|
|
2017-02-17 00:46:39 +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
|
|
|
|
2017-04-19 23:51:55 +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);
|
|
|
|
}
|
2016-01-06 23:28:11 +00:00
|
|
|
};
|
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;
|
2017-04-19 23:51:55 +00:00
|
|
|
if (tab.isChannel()) {
|
2015-12-28 23:34:32 +00:00
|
|
|
leaveTitle = 'Leave';
|
2017-04-19 23:51:55 +00:00
|
|
|
} 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">
|
2016-02-17 00:49:27 +00:00
|
|
|
<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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|