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.

57 lines
1.6 KiB

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