You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

  1. import { connect } from 'react-redux';
  2. import PureRenderMixin from 'react-addons-pure-render-mixin';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import LoadingIndicator from '../../components/loading_indicator';
  5. import { fetchFollowing } from '../../actions/accounts';
  6. import { ScrollContainer } from 'react-router-scroll';
  7. import AccountContainer from '../followers/containers/account_container';
  8. const mapStateToProps = (state, props) => ({
  9. accountIds: state.getIn(['user_lists', 'following', Number(props.params.accountId)])
  10. });
  11. const Following = React.createClass({
  12. propTypes: {
  13. params: React.PropTypes.object.isRequired,
  14. dispatch: React.PropTypes.func.isRequired,
  15. accountIds: ImmutablePropTypes.list
  16. },
  17. mixins: [PureRenderMixin],
  18. componentWillMount () {
  19. this.props.dispatch(fetchFollowing(Number(this.props.params.accountId)));
  20. },
  21. componentWillReceiveProps(nextProps) {
  22. if (nextProps.params.accountId !== this.props.params.accountId && nextProps.params.accountId) {
  23. this.props.dispatch(fetchFollowing(Number(nextProps.params.accountId)));
  24. }
  25. },
  26. render () {
  27. const { accountIds } = this.props;
  28. if (!accountIds) {
  29. return <LoadingIndicator />;
  30. }
  31. return (
  32. <ScrollContainer scrollKey='following'>
  33. <div style={{ overflowY: 'scroll', flex: '1 1 auto', overflowX: 'hidden' }} className='scrollable'>
  34. {accountIds.map(id => <AccountContainer key={id} id={id} withNote={false} />)}
  35. </div>
  36. </ScrollContainer>
  37. );
  38. }
  39. });
  40. export default connect(mapStateToProps)(Following);