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.

65 lines
1.9 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. import { Helmet } from 'react-helmet';
  12. const messages = defineMessages({
  13. heading: { id: 'column.pins', defaultMessage: 'Pinned post' },
  14. });
  15. const mapStateToProps = state => ({
  16. statusIds: state.getIn(['status_lists', 'pins', 'items']),
  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. 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' heading={intl.formatMessage(messages.heading)} ref={this.setRef}>
  40. <ColumnBackButtonSlim />
  41. <StatusList
  42. statusIds={statusIds}
  43. scrollKey='pinned_statuses'
  44. hasMore={hasMore}
  45. bindToDocument={!multiColumn}
  46. />
  47. <Helmet>
  48. <meta name='robots' content='noindex' />
  49. </Helmet>
  50. </Column>
  51. );
  52. }
  53. }
  54. export default connect(mapStateToProps)(injectIntl(PinnedStatuses));