<commit_before>import { paging as pagingActions } from "apollos-core/dist/core/store";

const Pageable = {

  componentDidMount: function() {
    this._bindPageOnScroll = this._pageOnScroll.bind(this);
    window.addEventListener("scroll", this._bindPageOnScroll);
  },

  componentWillUnmount: function() {
    window.removeEventListener("scroll", this._bindPageOnScroll);
    this.props.dispatch(pagingActions.reset());
  },

  shouldComponentUpdate(nextProps, nextState) {
    if (nextProps.data.loading) return false

    return true;
  },

  _pageOnScroll: function(event) {
    if (this.props.paging.done) return

    if (window.scrollY / document.body.clientHeight > 0.8 && this.props.paging.shouldUpdate) {
      this.props.dispatch(pagingActions.pause());
      this.props.dispatch(pagingActions.increment());

      // wait a bit to prevent paging multiple times
      setTimeout(() => {
        this.props.dispatch(pagingActions.resume());
      }, 1000);
    }
  },

}
<commit_msg>adjust infinite scrolling to account for height of device<commit_after>import { paging as pagingActions } from "apollos-core/dist/core/store";

const Pageable = {

  componentDidMount: function() {
    this._bindPageOnScroll = this._pageOnScroll.bind(this);
    window.addEventListener("scroll", this._bindPageOnScroll);
  },

  componentWillUnmount: function() {
    window.removeEventListener("scroll", this._bindPageOnScroll);
    this.props.dispatch(pagingActions.reset());
  },

  shouldComponentUpdate(nextProps, nextState) {
    if (nextProps.data.loading) return false

    return true;
  },

  _pageOnScroll: function(event) {
    if (this.props.paging.done) return

    const scrollPosition = window.scrollY;
    const deviceHeight = window.outerHeight;
    const contentHeight = document.body.clientHeight;
    const threshold = 0.8;

    if ((scrollPosition + deviceHeight) / contentHeight > threshold && this.props.paging.shouldUpdate) {
      this.props.dispatch(pagingActions.pause());
      this.props.dispatch(pagingActions.increment());

      // wait a bit to prevent paging multiple times
      setTimeout(() => {
        this.props.dispatch(pagingActions.resume());
      }, 1000);
    }
  },

}

{'fraction_non_alphanumeric': 0.12398190045248869, 'fraction_numerical': 0.005429864253393665, 'mean_word_length': 3.7548387096774194, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2884977', 'n_tokens_mistral': 663, 'n_tokens_neox': 640, 'n_words': 121}