闭社主体 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.

59 lines
1.7 KiB

  1. import { connect } from 'react-redux';
  2. import PropTypes from 'prop-types';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import LoadingIndicator from '../../components/loading_indicator';
  5. import { fetchReblogs } from '../../actions/interactions';
  6. import { ScrollContainer } from 'react-router-scroll';
  7. import AccountContainer from '../../containers/account_container';
  8. import Column from '../ui/components/column';
  9. import ColumnBackButton from '../../components/column_back_button';
  10. const mapStateToProps = (state, props) => ({
  11. accountIds: state.getIn(['user_lists', 'reblogged_by', Number(props.params.statusId)])
  12. });
  13. class Reblogs extends React.PureComponent {
  14. componentWillMount () {
  15. this.props.dispatch(fetchReblogs(Number(this.props.params.statusId)));
  16. }
  17. componentWillReceiveProps(nextProps) {
  18. if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
  19. this.props.dispatch(fetchReblogs(Number(nextProps.params.statusId)));
  20. }
  21. }
  22. render () {
  23. const { accountIds } = this.props;
  24. if (!accountIds) {
  25. return (
  26. <Column>
  27. <LoadingIndicator />
  28. </Column>
  29. );
  30. }
  31. return (
  32. <Column>
  33. <ColumnBackButton />
  34. <ScrollContainer scrollKey='reblogs'>
  35. <div className='scrollable reblogs'>
  36. {accountIds.map(id => <AccountContainer key={id} id={id} withNote={false} />)}
  37. </div>
  38. </ScrollContainer>
  39. </Column>
  40. );
  41. }
  42. }
  43. Reblogs.propTypes = {
  44. params: PropTypes.object.isRequired,
  45. dispatch: PropTypes.func.isRequired,
  46. accountIds: ImmutablePropTypes.list
  47. };
  48. export default connect(mapStateToProps)(Reblogs);