闭社主体 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.

68 lines
1.9 KiB

  1. import { connect } from 'react-redux';
  2. import PureRenderMixin from 'react-addons-pure-render-mixin';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import LoadingIndicator from '../../components/loading_indicator';
  5. import { ScrollContainer } from 'react-router-scroll';
  6. import Column from '../ui/components/column';
  7. import ColumnBackButtonSlim from '../../components/column_back_button_slim';
  8. import AccountContainer from '../../containers/account_container';
  9. import { fetchMutes, expandMutes } from '../../actions/mutes';
  10. import { defineMessages, injectIntl } from 'react-intl';
  11. const messages = defineMessages({
  12. heading: { id: 'column.mutes', defaultMessage: 'Muted users' }
  13. });
  14. const mapStateToProps = state => ({
  15. accountIds: state.getIn(['user_lists', 'mutes', 'items'])
  16. });
  17. const Mutes = React.createClass({
  18. propTypes: {
  19. params: React.PropTypes.object.isRequired,
  20. dispatch: React.PropTypes.func.isRequired,
  21. accountIds: ImmutablePropTypes.list,
  22. intl: React.PropTypes.object.isRequired
  23. },
  24. mixins: [PureRenderMixin],
  25. componentWillMount () {
  26. this.props.dispatch(fetchMutes());
  27. },
  28. handleScroll (e) {
  29. const { scrollTop, scrollHeight, clientHeight } = e.target;
  30. if (scrollTop === scrollHeight - clientHeight) {
  31. this.props.dispatch(expandMutes());
  32. }
  33. },
  34. render () {
  35. const { intl, accountIds } = this.props;
  36. if (!accountIds) {
  37. return (
  38. <Column>
  39. <LoadingIndicator />
  40. </Column>
  41. );
  42. }
  43. return (
  44. <Column icon='volume-off' heading={intl.formatMessage(messages.heading)}>
  45. <ColumnBackButtonSlim />
  46. <ScrollContainer scrollKey='mutes'>
  47. <div className='scrollable' onScroll={this.handleScroll}>
  48. {accountIds.map(id =>
  49. <AccountContainer key={id} id={id} />
  50. )}
  51. </div>
  52. </ScrollContainer>
  53. </Column>
  54. );
  55. }
  56. });
  57. export default connect(mapStateToProps)(injectIntl(Mutes));