You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.9 KiB

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import ImmutablePureComponent from 'react-immutable-pure-component';
  5. import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
  6. import Hashtag from 'mastodon/components/hashtag';
  7. const messages = defineMessages({
  8. lastStatusAt: { id: 'account.featured_tags.last_status_at', defaultMessage: 'Last post on {date}' },
  9. empty: { id: 'account.featured_tags.last_status_never', defaultMessage: 'No posts' },
  10. });
  11. class FeaturedTags extends ImmutablePureComponent {
  12. static contextTypes = {
  13. router: PropTypes.object,
  14. };
  15. static propTypes = {
  16. account: ImmutablePropTypes.map,
  17. featuredTags: ImmutablePropTypes.list,
  18. tagged: PropTypes.string,
  19. intl: PropTypes.object.isRequired,
  20. };
  21. render () {
  22. const { account, featuredTags, intl } = this.props;
  23. if (!account || account.get('suspended') || featuredTags.isEmpty()) {
  24. return null;
  25. }
  26. return (
  27. <div className='getting-started__trends'>
  28. <h4><FormattedMessage id='account.featured_tags.title' defaultMessage="{name}'s featured hashtags" values={{ name: <bdi dangerouslySetInnerHTML={{ __html: account.get('display_name_html') }} /> }} /></h4>
  29. {featuredTags.take(3).map(featuredTag => (
  30. <Hashtag
  31. key={featuredTag.get('name')}
  32. name={featuredTag.get('name')}
  33. to={`/@${account.get('acct')}/tagged/${featuredTag.get('name')}`}
  34. uses={featuredTag.get('statuses_count') * 1}
  35. withGraph={false}
  36. description={((featuredTag.get('statuses_count') * 1) > 0) ? intl.formatMessage(messages.lastStatusAt, { date: intl.formatDate(featuredTag.get('last_status_at'), { month: 'short', day: '2-digit' }) }) : intl.formatMessage(messages.empty)}
  37. />
  38. ))}
  39. </div>
  40. );
  41. }
  42. }
  43. export default injectIntl(FeaturedTags);