闭社主体 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.7 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 { fetchPinnedStatuses } from '../../actions/pin_statuses';
  6. import Column from '../ui/components/column';
  7. import ColumnBackButtonSlim from '../../components/column_back_button_slim';
  8. import StatusList from '../../components/status_list';
  9. import { defineMessages, injectIntl } from 'react-intl';
  10. import ImmutablePureComponent from 'react-immutable-pure-component';
  11. const messages = defineMessages({
  12. heading: { id: 'column.pins', defaultMessage: 'Pinned toot' },
  13. });
  14. const mapStateToProps = state => ({
  15. statusIds: state.getIn(['status_lists', 'pins', 'items']),
  16. hasMore: !!state.getIn(['status_lists', 'pins', 'next']),
  17. });
  18. export default @connect(mapStateToProps)
  19. @injectIntl
  20. class PinnedStatuses extends ImmutablePureComponent {
  21. static propTypes = {
  22. dispatch: PropTypes.func.isRequired,
  23. shouldUpdateScroll: PropTypes.func,
  24. statusIds: ImmutablePropTypes.list.isRequired,
  25. intl: PropTypes.object.isRequired,
  26. hasMore: PropTypes.bool.isRequired,
  27. };
  28. componentWillMount () {
  29. this.props.dispatch(fetchPinnedStatuses());
  30. }
  31. handleHeaderClick = () => {
  32. this.column.scrollTop();
  33. }
  34. setRef = c => {
  35. this.column = c;
  36. }
  37. render () {
  38. const { intl, shouldUpdateScroll, statusIds, hasMore } = this.props;
  39. return (
  40. <Column icon='thumb-tack' heading={intl.formatMessage(messages.heading)} ref={this.setRef}>
  41. <ColumnBackButtonSlim />
  42. <StatusList
  43. statusIds={statusIds}
  44. scrollKey='pinned_statuses'
  45. hasMore={hasMore}
  46. shouldUpdateScroll={shouldUpdateScroll}
  47. />
  48. </Column>
  49. );
  50. }
  51. }