index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. export default @connect(mapStateToProps)
  20. @injectIntl
  21. class PinnedStatuses extends ImmutablePureComponent {
  22. static propTypes = {
  23. dispatch: PropTypes.func.isRequired,
  24. statusIds: ImmutablePropTypes.list.isRequired,
  25. intl: PropTypes.object.isRequired,
  26. hasMore: PropTypes.bool.isRequired,
  27. multiColumn: PropTypes.bool,
  28. };
  29. componentWillMount () {
  30. this.props.dispatch(fetchPinnedStatuses());
  31. }
  32. handleHeaderClick = () => {
  33. this.column.scrollTop();
  34. }
  35. setRef = c => {
  36. this.column = c;
  37. }
  38. render () {
  39. const { intl, statusIds, hasMore, multiColumn } = this.props;
  40. return (
  41. <Column bindToDocument={!multiColumn} icon='thumb-tack' heading={intl.formatMessage(messages.heading)} ref={this.setRef}>
  42. <ColumnBackButtonSlim />
  43. <StatusList
  44. statusIds={statusIds}
  45. scrollKey='pinned_statuses'
  46. hasMore={hasMore}
  47. bindToDocument={!multiColumn}
  48. />
  49. <Helmet>
  50. <meta name='robots' content='noindex' />
  51. </Helmet>
  52. </Column>
  53. );
  54. }
  55. }