<commit_before>import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { replace } from 'react-router-redux'
import debounce from 'lodash/debounce'
import set from 'lodash/set'
import { isAndroid, isElloAndroid } from '../lib/jello'
import { ONBOARDING_VERSION } from '../constants/application_types'
import { FORM_CONTROL_STATUS as STATUS } from '../constants/status_types'
import { selectHomeStream } from '../selectors/gui'
import {
  selectBuildVersion,
  selectBundleId,
  selectMarketingVersion,
  selectRegistrationId,
  selectWebOnboardingVersion,
} from '../selectors/profile'
import { loadProfile, requestPushSubscription, saveProfile } from '../actions/profile'
import { signIn } from '../actions/authentication'
import TextControl from '../components/forms/TextControl'
import PasswordControl from '../components/forms/PasswordControl'
import FormButton from '../components/forms/FormButton'
import {
  isFormValid,
  getUserStateFromClient,
  getPasswordState,
} from '../components/forms/Validators'
import { MainView } from '../components/views/MainView'
import { loginToken } from '../networking/api'

function renderStatus(state) {
  return () => {
    if (state.status === STATUS.FAILURE) {
      return <p className="HoppyStatusMessage hasContent">{state.message}</p>
    }
    return <p className="HoppyStatusMessage"><span /></p>
  }
}

function mapStateToProps(state) {
  const obj = {
    homeStream: selectHomeStream(state),
    webOnboardingVersionSeen: selectWebOnboardingVersion(state),
  }
  if (isElloAndroid()) {
    obj.buildVersion = selectBuildVersion(state)
    obj.bundleId = selectBundleId(state)
    obj.marketingVersion = selectMarketingVersion(state)
    obj.registrationId = selectRegistrationId(state)
  }
  return obj
}

class EnterContainer extends Component {

  static propTypes = {
    buildVersion: PropTypes.string,
    bundleId: PropTypes.string,
    dispatch: PropTypes.func.isRequired,
    homeStream: PropTypes.string,
    marketingVersion: PropTypes.string,
    registrationId: PropTypes.string,
    webOnboardingVersionSeen: PropTypes.string,
  }

  componentWillMount() {
    this.state = {
      passwordState: { status: STATUS.INDETERMINATE, message: '' },
      showPasswordError: false,
      showUserError: false,
      userState: { status: STATUS.INDETERMINATE, message: '' },
    }
    this.userValue = ''
    this.passwordValue = ''

    this.delayedShowUserError = debounce(this.delayedShowUserError, 1000)
    this.delayedShowPasswordError = debounce(this.delayedShowPasswordError, 1000)
  }

  componentWillReceiveProps(nextProps) {
    if (typeof this.props.webOnboardingVersionSeen === 'undefined' &&<commit_msg>Subclass a PureComponent for ease of use<commit_after>import React, { PropTypes, PureComponent } from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { replace } from 'react-router-redux'
import debounce from 'lodash/debounce'
import set from 'lodash/set'
import { isAndroid, isElloAndroid } from '../lib/jello'
import { ONBOARDING_VERSION } from '../constants/application_types'
import { FORM_CONTROL_STATUS as STATUS } from '../constants/status_types'
import { selectHomeStream } from '../selectors/gui'
import {
  selectBuildVersion,
  selectBundleId,
  selectMarketingVersion,
  selectRegistrationId,
  selectWebOnboardingVersion,
} from '../selectors/profile'
import { loadProfile, requestPushSubscription, saveProfile } from '../actions/profile'
import { signIn } from '../actions/authentication'
import TextControl from '../components/forms/TextControl'
import PasswordControl from '../components/forms/PasswordControl'
import FormButton from '../components/forms/FormButton'
import {
  isFormValid,
  getUserStateFromClient,
  getPasswordState,
} from '../components/forms/Validators'
import { MainView } from '../components/views/MainView'
import { loginToken } from '../networking/api'

function renderStatus(state) {
  return () => {
    if (state.status === STATUS.FAILURE) {
      return <p className="HoppyStatusMessage hasContent">{state.message}</p>
    }
    return <p className="HoppyStatusMessage"><span /></p>
  }
}

function mapStateToProps(state) {
  const obj = {
    homeStream: selectHomeStream(state),
    webOnboardingVersionSeen: selectWebOnboardingVersion(state),
  }
  if (isElloAndroid()) {
    obj.buildVersion = selectBuildVersion(state)
    obj.bundleId = selectBundleId(state)
    obj.marketingVersion = selectMarketingVersion(state)
    obj.registrationId = selectRegistrationId(state)
  }
  return obj
}

class EnterContainer extends PureComponent {

  static propTypes = {
    buildVersion: PropTypes.string,
    bundleId: PropTypes.string,
    dispatch: PropTypes.func.isRequired,
    homeStream: PropTypes.string,
    marketingVersion: PropTypes.string,
    registrationId: PropTypes.string,
    webOnboardingVersionSeen: PropTypes.string,
  }

  componentWillMount() {
    this.state = {
      passwordState: { status: STATUS.INDETERMINATE, message: '' },
      showPasswordError: false,
      showUserError: false,
      userState: { status: STATUS.INDETERMINATE, message: '' },
    }
    this.userValue = ''
    this.passwordValue = ''

    this.delayedShowUserError = debounce(this.delayedShowUserError, 1000)
    this.delayedShowPasswordError = debounce(this.delayedShowPasswordError, 1000)
  }

  componentWillReceiveProps(nextProps) {
    if (typeof this.props.webOnboardingVersionSeen === 'undefined' &&
{'fraction_non_alphanumeric': 0.11317354478284375, 'fraction_numerical': 0.0028834024148495225, 'mean_word_length': 4.489614243323442, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '4418698', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1598, 'n_words': 346}