import React from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import { FormattedMessage } from 'react-intl' import ImmutablePureComponent from 'react-immutable-pure-component' import ImmutablePropTypes from 'react-immutable-proptypes' import debounce from 'lodash.debounce' import { me } from '../initial_state' import { fetchFollowRequests, expandFollowRequests } from '../actions/accounts' import AccountAuthorize from '../components/account_authorize' import Block from '../components/block' import ScrollableList from '../components/scrollable_list' import Text from '../components/text' class FollowRequests extends ImmutablePureComponent { componentWillMount () { this.props.onFetchFollowRequests() } handleLoadMore = debounce(() => { this.props.onExpandFollowRequests() }, 300, { leading: true }) render () { const { accountIds, hasMore, isLoading, locked, } = this.props const unlockedPrependMessage = locked ? null : (
) return ( {unlockedPrependMessage} } > { accountIds && accountIds.map((id) => ) } ) } } const mapStateToProps = (state) => ({ accountIds: state.getIn(['user_lists', 'follow_requests', me, 'items']), isLoading: state.getIn(['user_lists', 'follow_requests', me, 'isLoading']), hasMore: !!state.getIn(['user_lists', 'follow_requests', me, 'next']), locked: !!state.getIn(['accounts', me, 'locked']), }) const mapDispatchToProps = (dispatch) => ({ onFetchFollowRequests() { dispatch(fetchFollowRequests()) }, onExpandFollowRequests() { dispatch(expandFollowRequests()) }, }) FollowRequests.propTypes = { accountIds: ImmutablePropTypes.list, hasMore: PropTypes.bool, isLoading: PropTypes.bool, locked: PropTypes.bool, onFetchFollowRequests: PropTypes.func.isRequired, onExpandFollowRequests: PropTypes.func.isRequired, } export default connect(mapStateToProps, mapDispatchToProps)(FollowRequests)