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

60 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. @connect(mapStateToProps)
  16. export default class Favourites extends ImmutablePureComponent {
  17. static propTypes = {
  18. params: PropTypes.object.isRequired,
  19. dispatch: PropTypes.func.isRequired,
  20. accountIds: ImmutablePropTypes.list,
  21. };
  22. componentWillMount () {
  23. this.props.dispatch(fetchFavourites(Number(this.props.params.statusId)));
  24. }
  25. componentWillReceiveProps (nextProps) {
  26. if (nextProps.params.statusId !== this.props.params.statusId && nextProps.params.statusId) {
  27. this.props.dispatch(fetchFavourites(Number(nextProps.params.statusId)));
  28. }
  29. }
  30. render () {
  31. const { accountIds } = this.props;
  32. if (!accountIds) {
  33. return (
  34. <Column>
  35. <LoadingIndicator />
  36. </Column>
  37. );
  38. }
  39. return (
  40. <Column>
  41. <ColumnBackButton />
  42. <ScrollContainer scrollKey='favourites'>
  43. <div className='scrollable'>
  44. {accountIds.map(id => <AccountContainer key={id} id={id} withNote={false} />)}
  45. </div>
  46. </ScrollContainer>
  47. </Column>
  48. );
  49. }
  50. }