<commit_before>import {graphql, createPaginationContainer} from 'react-relay';
import PropTypes from 'prop-types';
import React from 'react';

import {PAGE_SIZE, PAGINATION_WAIT_TIME_MS} from '../helpers';

export class ReviewCommentsController extends React.Component {

  static propTypes = {
    aggregateComments: PropTypes.func.isRequired,
    review: PropTypes.shape({
      id: PropTypes.string.isRequired,
      comments: PropTypes.arrayOf(PropTypes.object).isRequired,
    }),
    relay: PropTypes.shape({
      hasMore: PropTypes.func.isRequired,
      loadMore: PropTypes.func.isRequired,
      isLoading: PropTypes.func.isRequired,
    }).isRequired,
  }

  componentDidMount() {
    this.props.aggregateComments(this.props.review.id, this.props.review.comments);
    this._attemptToLoadMoreComments();
  }

  _loadMoreComments = () => {
    this.props.relay.loadMore(
      PAGE_SIZE,
      error => {
        this._attemptToLoadMoreComments();
        if (error) {
          // eslint-disable-next-line no-console
          console.error(error);
        }
      },
    );
  }

  _attemptToLoadMoreComments = () => {
    if (!this.props.relay.hasMore()) {
      return;
    }

    if (this.props.relay.isLoading()) {
      setTimeout(() => {
        this._loadMoreComments();
      }, PAGINATION_WAIT_TIME_MS);
    } else {
      this._loadMoreComments();
    }
  }

  render() {
    return null;
  }
}

export default createPaginationContainer(ReviewCommentsController, {
  review: graphql`
    fragment prReviewCommentsContainer_review on PullRequestReview
    @argumentDefinitions(
      commentCount: {type: "Int!"},
      commentCursor: {type: "String"}
    ) {
      id
      comments(
        first: $commentCount,
        after: $commentCursor
      ) @connection(key: "PrReviewCommentsContainer_comments") {
        pageInfo {
          hasNextPage<commit_msg>follow bare container component naming convention<commit_after>import {graphql, createPaginationContainer} from 'react-relay';
import PropTypes from 'prop-types';
import React from 'react';

import {PAGE_SIZE, PAGINATION_WAIT_TIME_MS} from '../helpers';

export class BarePullRequestReviewCommentsContainer extends React.Component {

  static propTypes = {
    aggregateComments: PropTypes.func.isRequired,
    review: PropTypes.shape({
      id: PropTypes.string.isRequired,
      comments: PropTypes.arrayOf(PropTypes.object).isRequired,
    }),
    relay: PropTypes.shape({
      hasMore: PropTypes.func.isRequired,
      loadMore: PropTypes.func.isRequired,
      isLoading: PropTypes.func.isRequired,
    }).isRequired,
  }

  componentDidMount() {
    this.props.aggregateComments(this.props.review.id, this.props.review.comments);
    this._attemptToLoadMoreComments();
  }

  _loadMoreComments = () => {
    this.props.relay.loadMore(
      PAGE_SIZE,
      error => {
        this._attemptToLoadMoreComments();
        if (error) {
          // eslint-disable-next-line no-console
          console.error(error);
        }
      },
    );
  }

  _attemptToLoadMoreComments = () => {
    if (!this.props.relay.hasMore()) {
      return;
    }

    if (this.props.relay.isLoading()) {
      setTimeout(() => {
        this._loadMoreComments();
      }, PAGINATION_WAIT_TIME_MS);
    } else {
      this._loadMoreComments();
    }
  }

  render() {
    return null;
  }
}

export default createPaginationContainer(BarePullRequestReviewCommentsContainer, {
  review: graphql`
    fragment prReviewCommentsContainer_review on PullRequestReview
    @argumentDefinitions(
      commentCount: {type: "Int!"},
      commentCursor: {type: "String"}
    ) {
      id
      comments(
        first: $commentCount,
        after: $commentCursor
      ) @connection(key: "PrReviewCommentsContainer_comments") {
        pageInfo {
          hasNextPage
{'fraction_non_alphanumeric': 0.1154649947753396, 'fraction_numerical': 0.0, 'mean_word_length': 2.9802494802494803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1207184', 'n_tokens_mistral': 1151, 'n_tokens_neox': 1131, 'n_words': 196}