2017-02-17 00:46:39 +00:00
|
|
|
import React, { PureComponent } from 'react';
|
2015-12-28 23:34:32 +00:00
|
|
|
|
2017-02-17 00:46:39 +00:00
|
|
|
export default class Message extends PureComponent {
|
2015-12-28 23:34:32 +00:00
|
|
|
handleSenderClick = () => {
|
|
|
|
const { message, openPrivateChat, select } = this.props;
|
|
|
|
|
|
|
|
openPrivateChat(message.server, message.from);
|
|
|
|
select(message.server, message.from, true);
|
2016-01-06 23:28:11 +00:00
|
|
|
};
|
2015-12-28 23:34:32 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const { message } = this.props;
|
2017-04-17 02:11:45 +00:00
|
|
|
const className = message.type ? `message message-${message.type}` : 'message';
|
2016-02-16 21:43:25 +00:00
|
|
|
const style = {
|
|
|
|
paddingLeft: `${window.messageIndent + 15}px`,
|
2017-03-23 19:38:27 +00:00
|
|
|
textIndent: `-${window.messageIndent}px`,
|
|
|
|
...this.props.style
|
2016-02-16 21:43:25 +00:00
|
|
|
};
|
|
|
|
|
2015-12-28 23:34:32 +00:00
|
|
|
return (
|
2017-04-17 02:11:45 +00:00
|
|
|
<p className={className} style={style}>
|
|
|
|
<span className="message-time">{message.time}</span>
|
|
|
|
{message.from &&
|
|
|
|
<span className="message-sender" onClick={this.handleSenderClick}>
|
|
|
|
{' '}{message.from}
|
|
|
|
</span>
|
|
|
|
}{' '}{message.message}
|
2015-12-28 23:34:32 +00:00
|
|
|
</p>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|