2015-12-28 23:34:32 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { List } from 'immutable';
|
|
|
|
import pure from 'pure-render-decorator';
|
|
|
|
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
|
|
|
|
|
|
|
@pure
|
|
|
|
export default class ChatTitle extends Component {
|
|
|
|
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.channel) {
|
2016-01-05 18:29:22 +00:00
|
|
|
part([tab.channel], tab.server);
|
2015-12-28 23:34:32 +00:00
|
|
|
} else if (tab.user) {
|
|
|
|
closePrivateChat(tab.server, tab.user);
|
|
|
|
} 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;
|
2016-02-17 00:49:27 +00:00
|
|
|
const _topic = channel.get('topic');
|
|
|
|
const topic = _topic ? linkify(_topic) : null;
|
2015-12-28 23:34:32 +00:00
|
|
|
|
|
|
|
let leaveTitle;
|
|
|
|
if (tab.channel) {
|
|
|
|
leaveTitle = 'Leave';
|
|
|
|
} else if (tab.user) {
|
|
|
|
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>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|