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.

68 lines
2.0 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 { ScrollContainer } from 'react-router-scroll';
  6. import Column from '../ui/components/column';
  7. import ColumnBackButtonSlim from '../../components/column_back_button_slim';
  8. import AccountAuthorizeContainer from './containers/account_authorize_container';
  9. import { fetchFollowRequests, expandFollowRequests } from '../../actions/accounts';
  10. import { defineMessages, injectIntl } from 'react-intl';
  11. const messages = defineMessages({
  12. heading: { id: 'column.follow_requests', defaultMessage: 'Follow requests' }
  13. });
  14. const mapStateToProps = state => ({
  15. accountIds: state.getIn(['user_lists', 'follow_requests', 'items'])
  16. });
  17. const FollowRequests = React.createClass({
  18. propTypes: {
  19. params: React.PropTypes.object.isRequired,
  20. dispatch: React.PropTypes.func.isRequired,
  21. accountIds: ImmutablePropTypes.list,
  22. intl: React.PropTypes.object.isRequired
  23. },
  24. mixins: [PureRenderMixin],
  25. componentWillMount () {
  26. this.props.dispatch(fetchFollowRequests());
  27. },
  28. handleScroll (e) {
  29. const { scrollTop, scrollHeight, clientHeight } = e.target;
  30. if (scrollTop === scrollHeight - clientHeight) {
  31. this.props.dispatch(expandFollowRequests());
  32. }
  33. },
  34. render () {
  35. const { intl, accountIds } = this.props;
  36. if (!accountIds) {
  37. return (
  38. <Column>
  39. <LoadingIndicator />
  40. </Column>
  41. );
  42. }
  43. return (
  44. <Column icon='users' heading={intl.formatMessage(messages.heading)}>
  45. <ColumnBackButtonSlim />
  46. <ScrollContainer scrollKey='follow_requests'>
  47. <div className='scrollable' onScroll={this.handleScroll}>
  48. {accountIds.map(id =>
  49. <AccountAuthorizeContainer key={id} id={id} />
  50. )}
  51. </div>
  52. </ScrollContainer>
  53. </Column>
  54. );
  55. }
  56. });
  57. export default connect(mapStateToProps)(injectIntl(FollowRequests));