<commit_before>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import { asyncConnect } from 'redux-connect';
import Helmet from 'react-helmet';
import { func, object } from 'prop-types';
import config from './config';

import { isLoaded as isAuthLoaded, load as loadAuth } from '../../redux/modules/auth';
import styles from './App.scss';

@asyncConnect([{
  promise: ({ store: { dispatch, getState } }) => {
    const promises = [];
    const state = getState();
    if (!state.reduxAsyncConnect.loaded && !isAuthLoaded(state) && !state.auth.error) {
      promises.push(dispatch(loadAuth()));
    }
    return Promise.all(promises);
  }
}])
@connect(
  state => ({
    user: state.auth.user
  }),
  {
    pushState: push
  }
)
export default class App extends Component {
  static propTypes = {
    children: object,
    user: object,
    pushState: func.isRequired
  };

  static defaultProps = {
    children: null,
    user: null
  };

  componentWillReceiveProps(nextProps) {
    if (!this.props.user && nextProps.user) {
      // login
      this.props.pushState('/');
    } else if (this.props.user && !nextProps.user) {
      // logout
      this.props.pushState('/');
    }
  }

  render() {
    return (
      <div className={styles.app}>
        <Helmet {...config.meta.head} />
        <div className={styles.app__container}>{this.props.children}</div>
      </div>
    );
  }
}<commit_msg>[fix] origin app<commit_after>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import { asyncConnect } from 'redux-connect';
import Helmet from 'react-helmet';
import { object, func } from 'prop-types';
import { isLoaded as isAuthLoaded, load as loadAuth } from '../../redux/modules/auth';
import { Header, Footer } from '../../components';
import config from './config';
import styles from './App.scss';

const mapStateToProps = st => ({
  user: st.auth.user
});
const mapDispatchToProps = {
  pushState: push
};

class App extends Component {
  static propTypes = {
    children: object,
    // history: object, // eslint-disable-line
    pushState: func.isRequired,
    user: object
  };

  static defaultProps = {
    children: null,
    // history: null,
    user: null
  };

  componentWillReceiveProps(nextProps) {
    if (!this.props.user && nextProps.user) {
      // login
      this.props.pushState('/');
    } else if (this.props.user && !nextProps.user) {
      // logout
      this.props.pushState('/');
    }
  }

  render() {
    return (
      <div className={styles.app}>
        <Helmet {...config.meta.head} />
        <Header />
        <div className={styles.app__container}>{this.props.children}</div>
        <Footer />
      </div>
    );
  }
}

export default asyncConnect([{
  promise: ({ store: { dispatch, getState } }) => {
    const promises = [];
    const state = getState();
    if (!state.reduxAsyncConnect.loaded && !isAuthLoaded(state) && !state.auth.error) {
      promises.push(dispatch(loadAuth()));
    }
    return Promise.all(promises);
  }
}])(connect(mapStateToProps, mapDispatchToProps)(App));
{'fraction_non_alphanumeric': 0.16191669276542436, 'fraction_numerical': 0.0, 'mean_word_length': 2.94320987654321, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, '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': '1438602', 'n_tokens_mistral': 998, 'n_tokens_neox': 993, 'n_words': 233}