<commit_before>/*
 This file is a part of libertysoil.org website
 Copyright (C) 2017  Loki Education (Social Enterprise)

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react';
import noop from 'lodash/noop';
import omit from 'lodash/omit';
import { List } from 'immutable';

import LoadMore from './load-more';
import River from './river_of_posts';

export default class LoadableRiver extends React.Component {
  static defaultProps = {
    loadMoreLimit: 4,
    onAutoLoad: noop,
    onForceLoad: noop,
    river: List(),
    waiting: false
  };

  constructor(props, ...args) {
    super(props, ...args);

    this.state = {
      displayLoadMore: props.river.size > props.loadMoreLimit
    };
  }

  shouldComponentUpdate(nextProps, nextState) {
    return nextProps !== this.props
      || nextState.displayLoadMore !== this.state.displayLoadMore;
  }

  handleAutoLoad = async (...args) => {
    const displayLoadMore = await this.props.onAutoLoad(...args);

    if (displayLoadMore !== undefined) {
      this.setState({ displayLoadMore });
    }
  };

  handleForceLoad = async (...args) => {
    const displayLoadMore = await this.props.onForceLoad(...args);

    if (displayLoadMore !== undefined) {
      this.setState({ displayLoadMore });<commit_msg>Activate LoadMore button after change of url query<commit_after>/*
 This file is a part of libertysoil.org website
 Copyright (C) 2017  Loki Education (Social Enterprise)

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react';
import noop from 'lodash/noop';
import omit from 'lodash/omit';
import clone from 'lodash/clone';
import isEqual from 'lodash/isEqual';
import { List } from 'immutable';

import LoadMore from './load-more';
import River from './river_of_posts';

export default class LoadableRiver extends React.Component {
  static contextTypes = {
    router: React.PropTypes.func.isRequired
  };

  static defaultProps = {
    loadMoreLimit: 4,
    onAutoLoad: noop,
    onForceLoad: noop,
    river: List(),
    waiting: false
  };

  constructor(props, context, ...args) {
    super(props, context, ...args);

    this.state = {
      displayLoadMore: props.river.size > props.loadMoreLimit
    };

    this.query = clone(context.router.location.query);
  }

  componentWillReceiveProps(nextProps, nextContext) {
    const { query: nextQuery } = nextContext.router.location;
    if (!isEqual(this.query, nextQuery)) {
      this.setState({ displayLoadMore: true });
      this.query = clone(nextQuery);
    }
  }

  shouldComponentUpdate(nextProps, nextState) {
    return nextProps !== this.props
      || nextState.displayLoadMore !== this.state.displayLoadMore;
  }

  handleAutoLoad = async (...args) => {
    const displayLoadMore = await this.props.onAutoLoad(...args);

    if (displayLoadMore !== undefined) {
      this.setState({ displayLoadMore });
    }
  };

  handleForceLoad = async (...args) => {
    const displayLoadMore = await this.props.onForceLoad(...args);

    if (displayLoadMore !== undefined) {
      this.setState({ displayLoadMore });
{'fraction_non_alphanumeric': 0.1002805049088359, 'fraction_numerical': 0.002805049088359046, 'mean_word_length': 3.5912017167381975, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '647220', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1166, 'n_words': 435}