2022-01-10 14:17:52 -08:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-12-22 12:22:29 -08:00
|
|
|
import React from 'react';
|
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2022-01-10 14:17:52 -08:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2022-01-10 14:01:24 -08:00
|
|
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { connect } from 'react-redux';
|
2022-01-10 14:25:06 -08:00
|
|
|
|
2022-01-10 14:17:52 -08:00
|
|
|
import { getSettings } from 'soapbox/actions/settings';
|
2021-12-22 12:22:29 -08:00
|
|
|
import Avatar from 'soapbox/components/avatar';
|
|
|
|
import DisplayName from 'soapbox/components/display_name';
|
|
|
|
import Permalink from 'soapbox/components/permalink';
|
|
|
|
import RelativeTimestamp from 'soapbox/components/relative_timestamp';
|
2021-12-25 09:21:20 -08:00
|
|
|
import ActionButton from 'soapbox/features/ui/components/action_button';
|
2022-01-10 14:17:52 -08:00
|
|
|
import { makeGetAccount } from 'soapbox/selectors';
|
|
|
|
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
|
|
|
import SoapboxPropTypes from 'soapbox/utils/soapbox_prop_types';
|
2021-12-22 12:22:29 -08:00
|
|
|
|
|
|
|
const makeMapStateToProps = () => {
|
|
|
|
const getAccount = makeGetAccount();
|
|
|
|
|
|
|
|
const mapStateToProps = (state, { id }) => ({
|
2021-12-30 03:08:28 -08:00
|
|
|
me: state.get('me'),
|
2021-12-22 12:22:29 -08:00
|
|
|
account: getAccount(state, id),
|
|
|
|
autoPlayGif: getSettings(state).get('autoPlayGif'),
|
|
|
|
});
|
|
|
|
|
|
|
|
return mapStateToProps;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default @injectIntl
|
2021-12-25 09:21:20 -08:00
|
|
|
@connect(makeMapStateToProps)
|
2021-12-22 12:22:29 -08:00
|
|
|
class AccountCard extends ImmutablePureComponent {
|
|
|
|
|
|
|
|
static propTypes = {
|
2021-12-30 03:08:28 -08:00
|
|
|
me: SoapboxPropTypes.me,
|
2021-12-22 12:22:29 -08:00
|
|
|
account: ImmutablePropTypes.map.isRequired,
|
|
|
|
autoPlayGif: PropTypes.bool,
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2021-12-30 03:08:28 -08:00
|
|
|
const { account, autoPlayGif, me } = this.props;
|
|
|
|
|
|
|
|
const followedBy = me !== account.get('id') && account.getIn(['relationship', 'followed_by']);
|
2021-12-22 12:22:29 -08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className='directory__card'>
|
2021-12-30 03:08:28 -08:00
|
|
|
{followedBy &&
|
|
|
|
<div className='directory__card__info'>
|
|
|
|
<span className='relationship-tag'>
|
|
|
|
<FormattedMessage id='account.follows_you' defaultMessage='Follows you' />
|
|
|
|
</span>
|
|
|
|
</div>}
|
2021-12-25 09:21:20 -08:00
|
|
|
<div className='directory__card__action-button'>
|
|
|
|
<ActionButton account={account} small />
|
|
|
|
</div>
|
2021-12-22 12:22:29 -08:00
|
|
|
<div className='directory__card__img'>
|
|
|
|
<img src={autoPlayGif ? account.get('header') : account.get('header_static')} alt='' className='parallax' />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='directory__card__bar'>
|
2021-12-25 09:21:20 -08:00
|
|
|
<Permalink className='directory__card__bar__name' href={account.get('url')} to={`/@${account.get('acct')}`}>
|
2021-12-22 12:22:29 -08:00
|
|
|
<Avatar account={account} size={48} />
|
|
|
|
<DisplayName account={account} />
|
|
|
|
</Permalink>
|
|
|
|
</div>
|
|
|
|
|
2021-12-25 09:21:20 -08:00
|
|
|
<div className='directory__card__extra'>
|
|
|
|
<div
|
|
|
|
className={classNames('account__header__content', (account.get('note').length === 0 || account.get('note') === '<p></p>') && 'empty')}
|
|
|
|
dangerouslySetInnerHTML={{ __html: account.get('note_emojified') }}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-12-22 12:22:29 -08:00
|
|
|
|
|
|
|
<div className='directory__card__extra'>
|
|
|
|
<div className='accounts-table__count'>{shortNumberFormat(account.get('statuses_count'))} <small><FormattedMessage id='account.posts' defaultMessage='Toots' /></small></div>
|
|
|
|
<div className='accounts-table__count'>{shortNumberFormat(account.get('followers_count'))} <small><FormattedMessage id='account.followers' defaultMessage='Followers' /></small></div>
|
|
|
|
<div className='accounts-table__count'>{account.get('last_status_at') === null ? <FormattedMessage id='account.never_active' defaultMessage='Never' /> : <RelativeTimestamp timestamp={account.get('last_status_at')} />} <small><FormattedMessage id='account.last_status' defaultMessage='Last active' /></small></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|