index.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import PropTypes from 'prop-types';
  2. import { defineMessages, injectIntl } from 'react-intl';
  3. import { Helmet } from 'react-helmet';
  4. import ImmutablePropTypes from 'react-immutable-proptypes';
  5. import ImmutablePureComponent from 'react-immutable-pure-component';
  6. import { connect } from 'react-redux';
  7. import PushPinIcon from '@/material-icons/400-24px/push_pin.svg?react';
  8. import { getStatusList } from 'mastodon/selectors';
  9. import { fetchPinnedStatuses } from '../../actions/pin_statuses';
  10. import StatusList from '../../components/status_list';
  11. import Column from '../ui/components/column';
  12. const messages = defineMessages({
  13. heading: { id: 'column.pins', defaultMessage: 'Pinned post' },
  14. });
  15. const mapStateToProps = state => ({
  16. statusIds: getStatusList(state, 'pins'),
  17. hasMore: !!state.getIn(['status_lists', 'pins', 'next']),
  18. });
  19. class PinnedStatuses extends ImmutablePureComponent {
  20. static propTypes = {
  21. dispatch: PropTypes.func.isRequired,
  22. statusIds: ImmutablePropTypes.list.isRequired,
  23. intl: PropTypes.object.isRequired,
  24. hasMore: PropTypes.bool.isRequired,
  25. multiColumn: PropTypes.bool,
  26. };
  27. UNSAFE_componentWillMount () {
  28. this.props.dispatch(fetchPinnedStatuses());
  29. }
  30. handleHeaderClick = () => {
  31. this.column.scrollTop();
  32. };
  33. setRef = c => {
  34. this.column = c;
  35. };
  36. render () {
  37. const { intl, statusIds, hasMore, multiColumn } = this.props;
  38. return (
  39. <Column bindToDocument={!multiColumn} icon='thumb-tack' iconComponent={PushPinIcon} heading={intl.formatMessage(messages.heading)} ref={this.setRef} alwaysShowBackButton>
  40. <StatusList
  41. statusIds={statusIds}
  42. scrollKey='pinned_statuses'
  43. hasMore={hasMore}
  44. bindToDocument={!multiColumn}
  45. />
  46. <Helmet>
  47. <meta name='robots' content='noindex' />
  48. </Helmet>
  49. </Column>
  50. );
  51. }
  52. }
  53. export default connect(mapStateToProps)(injectIntl(PinnedStatuses));