2020-08-25 09:33:51 -07:00
|
|
|
import React from 'react';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import Avatar from '../../../components/avatar';
|
|
|
|
import DisplayName from '../../../components/display_name';
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2020-08-27 13:43:19 -07:00
|
|
|
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
2020-08-25 09:33:51 -07:00
|
|
|
|
2020-08-28 11:28:11 -07:00
|
|
|
export default class Chat extends ImmutablePureComponent {
|
2020-08-25 09:33:51 -07:00
|
|
|
|
|
|
|
static propTypes = {
|
2020-08-25 15:24:47 -07:00
|
|
|
chat: ImmutablePropTypes.map.isRequired,
|
2020-08-25 09:33:51 -07:00
|
|
|
onClick: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
|
|
|
handleClick = () => {
|
2020-08-25 15:24:47 -07:00
|
|
|
this.props.onClick(this.props.chat);
|
2020-08-25 09:33:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-08-25 15:24:47 -07:00
|
|
|
const { chat } = this.props;
|
|
|
|
if (!chat) return null;
|
|
|
|
const account = chat.get('account');
|
2020-08-27 13:43:19 -07:00
|
|
|
const unreadCount = chat.get('unread');
|
2020-08-25 09:33:51 -07:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='account'>
|
|
|
|
<button className='floating-link' onClick={this.handleClick} />
|
|
|
|
<div className='account__wrapper'>
|
|
|
|
<div key={account.get('id')} className='account__display-name'>
|
|
|
|
<div className='account__avatar-wrapper'>
|
|
|
|
<Avatar account={account} size={36} />
|
|
|
|
</div>
|
|
|
|
<DisplayName account={account} />
|
2020-08-27 13:43:19 -07:00
|
|
|
{unreadCount > 0 && <i className='icon-with-badge__badge'>{shortNumberFormat(unreadCount)}</i>}
|
2020-08-25 09:33:51 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|