闭社主体 forked from https://github.com/tootsuite/mastodon
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.

74 lines
2.2 KiB

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