import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePureComponent from 'react-immutable-pure-component'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; import { FormattedMessage } from 'react-intl'; import { fetchSuggestions } from 'soapbox/actions/suggestions_v2'; import Column from 'soapbox/features/ui/components/column'; import Account from './components/account'; import Button from 'soapbox/components/button'; const mapStateToProps = state => ({ suggestions: state.getIn(['suggestions_v2', 'items']), isLoading: state.getIn(['suggestions_v2', 'isLoading']), }); export default @connect(mapStateToProps) class FollowRecommendations extends ImmutablePureComponent { static contextTypes = { router: PropTypes.object.isRequired, }; static propTypes = { dispatch: PropTypes.func.isRequired, suggestions: ImmutablePropTypes.list, isLoading: PropTypes.bool, }; componentDidMount() { const { dispatch, suggestions } = this.props; // Don't re-fetch if we're e.g. navigating backwards to this page, // since we don't want followed accounts to disappear from the list if (suggestions.size === 0) { dispatch(fetchSuggestions(true)); } } handleDone = () => { const { router } = this.context; router.history.push('/'); } render() { const { suggestions, isLoading } = this.props; return (

{!isLoading && ( <>
{suggestions.size > 0 ? suggestions.map(suggestion => ( )) : (
)}
)}
); } }