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

63 lines
1.9 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 { fetchFavouritedStatuses, expandFavouritedStatuses } from '../../actions/favourites';
  6. import Column from '../ui/components/column';
  7. import StatusList from '../../components/status_list';
  8. import ColumnBackButtonSlim from '../../components/column_back_button_slim';
  9. import { defineMessages, injectIntl } from 'react-intl';
  10. const messages = defineMessages({
  11. heading: { id: 'column.favourites', defaultMessage: 'Favourites' }
  12. });
  13. const mapStateToProps = state => ({
  14. statusIds: state.getIn(['status_lists', 'favourites', 'items']),
  15. loaded: state.getIn(['status_lists', 'favourites', 'loaded']),
  16. me: state.getIn(['meta', 'me'])
  17. });
  18. const Favourites = React.createClass({
  19. propTypes: {
  20. params: React.PropTypes.object.isRequired,
  21. dispatch: React.PropTypes.func.isRequired,
  22. statusIds: ImmutablePropTypes.list.isRequired,
  23. loaded: React.PropTypes.bool,
  24. intl: React.PropTypes.object.isRequired,
  25. me: React.PropTypes.number.isRequired
  26. },
  27. mixins: [PureRenderMixin],
  28. componentWillMount () {
  29. this.props.dispatch(fetchFavouritedStatuses());
  30. },
  31. handleScrollToBottom () {
  32. this.props.dispatch(expandFavouritedStatuses());
  33. },
  34. render () {
  35. const { statusIds, loaded, intl, me } = this.props;
  36. if (!loaded) {
  37. return (
  38. <Column>
  39. <LoadingIndicator />
  40. </Column>
  41. );
  42. }
  43. return (
  44. <Column icon='star' heading={intl.formatMessage(messages.heading)}>
  45. <ColumnBackButtonSlim />
  46. <StatusList statusIds={statusIds} me={me} onScrollToBottom={this.handleScrollToBottom} />
  47. </Column>
  48. );
  49. }
  50. });
  51. export default connect(mapStateToProps)(injectIntl(Favourites));