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

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