2015-12-28 23:34:32 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { List } from 'immutable';
|
|
|
|
import Autolinker from 'autolinker';
|
|
|
|
import pure from 'pure-render-decorator';
|
|
|
|
import Navicon from '../components/Navicon';
|
|
|
|
|
|
|
|
@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() {
|
|
|
|
const { title, tab, channel, toggleSearch } = this.props;
|
2016-01-05 18:40:39 +00:00
|
|
|
const topic = Autolinker.link(channel.get('topic') || '', { stripPrefix: false });
|
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">
|
|
|
|
<span className="chat-topic" dangerouslySetInnerHTML={{ __html: topic }}></span>
|
|
|
|
</div>
|
|
|
|
<i className="icon-search" title="Search" onClick={toggleSearch} />
|
|
|
|
<i
|
|
|
|
className="icon-logout button-leave"
|
|
|
|
title={leaveTitle}
|
|
|
|
onClick={this.handleLeaveClick}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="userlist-bar">
|
|
|
|
<i className="icon-user" />
|
|
|
|
<span className="chat-usercount">{channel.get('users', List()).size || null}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|