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

61 lines
1.8 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 { fetchFavourites } from '../../actions/interactions';
  7. import { ScrollContainer } from 'react-router-scroll';
  8. import AccountContainer from '../../containers/account_container';
  9. import Column from '../ui/components/column';
  10. import ColumnBackButton from '../../components/column_back_button';
  11. import ImmutablePureComponent from 'react-immutable-pure-component';
  12. const mapStateToProps = (state, props) => ({
  13. accountIds: state.getIn(['user_lists', 'favourited_by', Number(props.params.statusId)]),
  14. });
  15. class Favourites extends ImmutablePureComponent {
  16. static propTypes = {
  17. params: PropTypes.object.isRequired,
  18. dispatch: PropTypes.func.isRequired,
  19. accountIds: ImmutablePropTypes.list,
  20. };
  21. componentWillMount () {
  22. this.props.dispatch(fetchFavourites(Number(this.props.params.statusId)));
  23. }
  24. componentWillReceiveProps (nextProps) {
  25. if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
  26. this.props.dispatch(fetchFavourites(Number(nextProps.params.statusId)));
  27. }
  28. }
  29. render () {
  30. const { accountIds } = this.props;
  31. if (!accountIds) {
  32. return (
  33. <Column>
  34. <LoadingIndicator />
  35. </Column>
  36. );
  37. }
  38. return (
  39. <Column>
  40. <ColumnBackButton />
  41. <ScrollContainer scrollKey='favourites'>
  42. <div className='scrollable'>
  43. {accountIds.map(id => <AccountContainer key={id} id={id} withNote={false} />)}
  44. </div>
  45. </ScrollContainer>
  46. </Column>
  47. );
  48. }
  49. }
  50. export default connect(mapStateToProps)(Favourites);