import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { ImmutableHashtag as Hashtag } from 'mastodon/components/hashtag'; import LoadingIndicator from 'mastodon/components/loading_indicator'; import { connect } from 'react-redux'; import { fetchTrendingHashtags } from 'mastodon/actions/trends'; import { FormattedMessage } from 'react-intl'; import DismissableBanner from 'mastodon/components/dismissable_banner'; const mapStateToProps = state => ({ hashtags: state.getIn(['trends', 'tags', 'items']), isLoadingHashtags: state.getIn(['trends', 'tags', 'isLoading']), }); class Tags extends React.PureComponent { static propTypes = { hashtags: ImmutablePropTypes.list, isLoading: PropTypes.bool, dispatch: PropTypes.func.isRequired, }; componentDidMount () { const { dispatch } = this.props; dispatch(fetchTrendingHashtags()); } render () { const { isLoading, hashtags } = this.props; const banner = ( ); if (!isLoading && hashtags.isEmpty()) { return (
{banner}
); } return (
{banner} {isLoading ? () : hashtags.map(hashtag => ( ))}
); } } export default connect(mapStateToProps)(Tags);