import React from 'react'; import PropTypes from 'prop-types'; import api from 'mastodon/api'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import Hashtag from 'mastodon/components/hashtag'; export default class Trends extends React.PureComponent { static propTypes = { limit: PropTypes.number.isRequired, }; state = { loading: true, data: null, }; componentDidMount () { const { limit } = this.props; api().get('/api/v1/admin/trends/tags', { params: { limit } }).then(res => { this.setState({ loading: false, data: res.data, }); }).catch(err => { console.error(err); }); } render () { const { limit } = this.props; const { loading, data } = this.state; let content; if (loading) { content = (
{Array.from(Array(limit)).map((_, i) => ( ))}
); } else { content = (
{data.map(hashtag => ( day.uses)} className={classNames(hashtag.requires_review && 'trends__item--requires-review', !hashtag.trendable && !hashtag.requires_review && 'trends__item--disabled')} /> ))}
); } return (

{content}
); } }