<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { logOut } from '../actions/user';
import { clearProjects } from '../actions/projects';
import { clearTasks } from '../actions/tasks';
import { clearLogs } from '../actions/timelog';
import Home from './Home';

class Logout extends React.Component {
  componentDidMount() {
    this.props.logMeOut();
    this.props.clearProjectsList();
    this.props.clearLogsList();
    this.props.clearTasksList();
  }

  componentWillReceiveProps(nextProps) {
    if (nextProps.user.loggedIn === false) {
      this.props.history.push('/');
    }
  }

  render() {
    return <Home />;
  }
}

Logout.defaultProps = {
  user: {},
};

Logout.propTypes = {
  logMeOut: PropTypes.func.isRequired,
  clearProjectsList: PropTypes.func.isRequired,
  clearLogsList: PropTypes.func.isRequired,
  clearTasksList: PropTypes.func.isRequired,
  history: PropTypes.object.isRequired,
  user: PropTypes.object,
};

const mapStateToProps = state => ({
  user: state.user,
});

const mapDispatchToProps = dispatch => ({
  logMeOut() {
    dispatch(logOut());
  },
  clearProjectsList() {
    dispatch(clearProjects());
  },
  clearTasksList() {
    dispatch(clearTasks());<commit_msg>bugfix constant reloading of a page<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { logOut } from '../actions/user';
import { clearProjects } from '../actions/projects';
import { clearTasks } from '../actions/tasks';
import { clearLogs } from '../actions/timelog';
import Spinner from './layout/Spinner';

class Logout extends React.Component {
  componentDidMount() {
    this.props.clearProjectsList();
    this.props.clearLogsList();
    this.props.clearTasksList();
    this.props.logMeOut();
  }

  componentWillReceiveProps(nextProps) {
    if (
      nextProps.user.loggedIn === false &&
      this.props.match.path === '/logmeout'
    ) {
      this.props.history.push('/login');
    }
  }

  render() {
    return <Spinner />;
  }
}

Logout.defaultProps = {
  user: {},
};

Logout.propTypes = {
  logMeOut: PropTypes.func.isRequired,
  clearProjectsList: PropTypes.func.isRequired,
  clearLogsList: PropTypes.func.isRequired,
  clearTasksList: PropTypes.func.isRequired,
  history: PropTypes.object.isRequired,
  user: PropTypes.object,
};

const mapStateToProps = state => ({
  user: state.user,
});

const mapDispatchToProps = dispatch => ({
  logMeOut() {
    dispatch(logOut());
  },
  clearProjectsList() {
    dispatch(clearProjects());
  },
  clearTasksList() {
    dispatch(clearTasks());
{'fraction_non_alphanumeric': 0.1511278195488722, 'fraction_numerical': 0.0, 'mean_word_length': 3.82940108892922, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '635273', 'n_tokens_mistral': 838, 'n_tokens_neox': 845, 'n_words': 162}