import PropTypes from 'prop-types'; import { PureComponent } from 'react'; import { FormattedMessage, FormattedHTMLMessage } from 'react-intl'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; import { fetchSuggestions } from 'mastodon/actions/suggestions'; import { markAsPartial } from 'mastodon/actions/timelines'; import Column from 'mastodon/components/column'; import ColumnBackButton from 'mastodon/components/column_back_button'; import { EmptyAccount } from 'mastodon/components/empty_account'; import Account from 'mastodon/containers/account_container'; import { me } from 'mastodon/initial_state'; import { makeGetAccount } from 'mastodon/selectors'; import ProgressIndicator from './components/progress_indicator'; const mapStateToProps = () => { const getAccount = makeGetAccount(); return state => ({ account: getAccount(state, me), suggestions: state.getIn(['suggestions', 'items']), isLoading: state.getIn(['suggestions', 'isLoading']), }); }; class Follows extends PureComponent { static propTypes = { onBack: PropTypes.func, dispatch: PropTypes.func.isRequired, suggestions: ImmutablePropTypes.list, account: ImmutablePropTypes.map, isLoading: PropTypes.bool, multiColumn: PropTypes.bool, }; componentDidMount () { const { dispatch } = this.props; dispatch(fetchSuggestions(true)); } componentWillUnmount () { const { dispatch } = this.props; dispatch(markAsPartial('home')); } render () { const { onBack, isLoading, suggestions, account, multiColumn } = this.props; let loadedContent; if (isLoading) { loadedContent = (new Array(8)).fill().map((_, i) => ); } else if (suggestions.isEmpty()) { loadedContent =
; } else { loadedContent = suggestions.map(suggestion => ); } return (

{loadedContent}

); } } export default connect(mapStateToProps)(Follows);