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.

59 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 'flavours/glitch/actions/pin_statuses';
  6. import Column from 'flavours/glitch/features/ui/components/column';
  7. import ColumnBackButtonSlim from 'flavours/glitch/components/column_back_button_slim';
  8. import StatusList from 'flavours/glitch/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. @connect(mapStateToProps)
  19. @injectIntl
  20. export default class PinnedStatuses extends ImmutablePureComponent {
  21. static propTypes = {
  22. dispatch: PropTypes.func.isRequired,
  23. statusIds: ImmutablePropTypes.list.isRequired,
  24. intl: PropTypes.object.isRequired,
  25. hasMore: PropTypes.bool.isRequired,
  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 } = this.props;
  38. return (
  39. <Column 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. />
  46. </Column>
  47. );
  48. }
  49. }