<commit_before>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { NonIdealState } from '@blueprintjs/core';
import Waypoint from 'react-waypoint';

import { fetchNextSearchResults } from 'src/actions';

import EntityList from 'src/components/EntityScreen/EntityList';
import SectionLoading from 'src/components/common/SectionLoading';

class SearchResult extends Component {
  constructor(props) {
    super(props);
    this.state = {
        isExpanding: false,
        result: props.result
    };
    this.bottomReachedHandler = this.bottomReachedHandler.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    this.setState({
      isExpanding: false,
      result: nextProps.result
    })
  }

  bottomReachedHandler() {
    const { fetchNextSearchResults } = this.props;
    let { result } = this.state;

    if (result.next) {
      this.setState({isExpanding: true});
      fetchNextSearchResults({ next: result.next }).then(({result: fresh}) => {
        result.next = fresh.next;
        result.results.push(...fresh.results);
        this.setState({
            result: result,
            isExpanding: false
        });
      });
    }
  }

  render() {
    const { result, isExpanding } = this.state;
    return (
      <div>
        { result.total === 0 &&
          <NonIdealState visual="search" title="No search results"
            description="Try making your search more general" />}
        <EntityList {...this.props} result={result} />
        { result.next && (
          <Waypoint onEnter={this.bottomReachedHandler} />
        )}
        { isExpanding && (
          <SectionLoading />
        )}
      </div>
    );
    
  }
}

SearchResult = connect(null, { fetchNextSearchResults })(SearchResult);
export default SearchResult;<commit_msg>Add Waypoint offset in result list<commit_after>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { NonIdealState } from '@blueprintjs/core';
import Waypoint from 'react-waypoint';

import { fetchNextSearchResults } from 'src/actions';

import EntityList from 'src/components/EntityScreen/EntityList';
import SectionLoading from 'src/components/common/SectionLoading';

class SearchResult extends Component {
  constructor(props) {
    super(props);
    this.state = {
        isExpanding: false,
        result: props.result
    };
    this.bottomReachedHandler = this.bottomReachedHandler.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    this.setState({
      isExpanding: false,
      result: nextProps.result
    })
  }

  bottomReachedHandler() {
    const { fetchNextSearchResults } = this.props;
    let { result } = this.state;

    if (result.next) {
      this.setState({isExpanding: true});
      fetchNextSearchResults({ next: result.next }).then(({result: fresh}) => {
        result.next = fresh.next;
        result.results.push(...fresh.results);
        this.setState({
            result: result,
            isExpanding: false
        });
      });
    }
  }

  render() {
    const { result, isExpanding } = this.state;
    return (
      <div>
        { result.total === 0 &&
          <NonIdealState visual="search" title="No search results"
            description="Try making your search more general" />}
        <EntityList {...this.props} result={result} />
        { result.next && (
          <Waypoint onEnter={this.bottomReachedHandler} bottomOffset="-600px" />
        )}
        { isExpanding && (
          <SectionLoading />
        )}
      </div>
    );
    
  }
}

SearchResult = connect(null, { fetchNextSearchResults })(SearchResult);
export default SearchResult;
{'fraction_non_alphanumeric': 0.12769440654843112, 'fraction_numerical': 0.001364256480218281, 'mean_word_length': 2.6733466933867733, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '6979444', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1037, 'n_words': 221}