logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

index.js (2125B)


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