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

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