2022-10-16 17:43:59 +11:00
import React from 'react' ;
import PropTypes from 'prop-types' ;
import ImmutablePropTypes from 'react-immutable-proptypes' ;
import ImmutablePureComponent from 'react-immutable-pure-component' ;
2022-10-19 20:30:59 +11:00
import { defineMessages , injectIntl , FormattedMessage } from 'react-intl' ;
import Hashtag from 'mastodon/components/hashtag' ;
2022-10-16 17:43:59 +11:00
const messages = defineMessages ( {
2022-10-19 20:30:59 +11:00
lastStatusAt : { id : 'account.featured_tags.last_status_at' , defaultMessage : 'Last post on {date}' } ,
empty : { id : 'account.featured_tags.last_status_never' , defaultMessage : 'No posts' } ,
2022-10-16 17:43:59 +11:00
} ) ;
2022-10-19 20:30:59 +11:00
export default @ injectIntl
2022-10-16 17:43:59 +11:00
class FeaturedTags extends ImmutablePureComponent {
static contextTypes = {
router : PropTypes . object ,
} ;
static propTypes = {
account : ImmutablePropTypes . map ,
featuredTags : ImmutablePropTypes . list ,
tagged : PropTypes . string ,
intl : PropTypes . object . isRequired ,
} ;
render ( ) {
2022-10-19 20:30:59 +11:00
const { account , featuredTags , intl } = this . props ;
2022-10-16 17:43:59 +11:00
2022-10-19 20:30:59 +11:00
if ( ! account || account . get ( 'suspended' ) || featuredTags . isEmpty ( ) ) {
2022-10-16 17:43:59 +11:00
return null ;
}
return (
2022-10-19 20:30:59 +11:00
< div className = 'getting-started__trends' >
< h4 > < FormattedMessage id = 'account.featured_tags.title' defaultMessage = "{name}'s featured hashtags" values = { { name : < bdi dangerouslySetInnerHTML = { { _ _html : account . get ( 'display_name_html' ) } } / > } } / > < / h4 >
2022-10-21 19:05:50 +11:00
{ featuredTags . take ( 3 ) . map ( featuredTag => (
2022-10-19 20:30:59 +11:00
< Hashtag
key = { featuredTag . get ( 'name' ) }
name = { featuredTag . get ( 'name' ) }
to = { ` /@ ${ account . get ( 'acct' ) } /tagged/ ${ featuredTag . get ( 'name' ) } ` }
2022-10-26 04:02:21 +11:00
uses = { featuredTag . get ( 'statuses_count' ) * 1 }
2022-10-19 20:30:59 +11:00
withGraph = { false }
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 ) }
/ >
) ) }
2022-10-16 17:43:59 +11:00
< / div >
) ;
}
}