<commit_before>import validator from 'validator'
import React from 'react'
import { connect } from 'react-redux'
import { prefetch } from 'react-fetcher'
import cx from 'classnames'
const { func, object, string } = React.PropTypes
import { UPLOAD_IMAGE, fetchCurrentUser, updateUserSettings, leaveCommunity, toggleUserSettingsSection } from '../../actions'
import { uploadImage } from '../../actions/uploadImage'
import A from '../../components/A'
import { formatDate } from '../../util/text'
import { debounce, get, sortBy } from 'lodash'
import { userAvatarUploadSettings, userBannerUploadSettings } from '../../constants'

@prefetch(({ dispatch, params: {id} }) => dispatch(fetchCurrentUser()))
@connect(({ people, userSettingsEditor, pending }, { location: { query } }) => {
  let expand = userSettingsEditor ? {...userSettingsEditor.expand} : {}
  switch (query.expand) {
    case 'password':
    case 'pro<PASSWORD>':
      expand.account = true
      break
    case undefined:
      break
    default:
      expand[query.expand] = true
  }

  return {
    expand,
    pending: get(pending, `${UPLOAD_IMAGE}.subject`),
    currentUser: people.current,
    ...userSettingsEditor
  }
})
export default class UserSettings extends React.Component {
  constructor (props) {
    super(props)
    this.state = {editing: {}, edited: {}, errors: {}}
  }

  static propTypes = {
    currentUser: object,
    dispatch: func,
    location: object,
    expand: object,
    pending: string<commit_msg>tweak handling of profile section expansion on page load<commit_after>import validator from 'validator'
import React from 'react'
import { connect } from 'react-redux'
import { prefetch } from 'react-fetcher'
import cx from 'classnames'
const { func, object, string } = React.PropTypes
import { UPLOAD_IMAGE, fetchCurrentUser, updateUserSettings, leaveCommunity, toggleUserSettingsSection } from '../../actions'
import { uploadImage } from '../../actions/uploadImage'
import A from '../../components/A'
import { formatDate } from '../../util/text'
import { debounce, get, sortBy } from 'lodash'
import { userAvatarUploadSettings, userBannerUploadSettings } from '../../constants'

@prefetch(({ dispatch, params: { id }, query }) => {
  let actions = [dispatch(fetchCurrentUser())]
  switch (query.expand) {
    case 'password':
    case 'prompts':
      actions.push(dispatch(toggleUserSettingsSection('account')))
      break
    case undefined:
      break
    default:
      actions.push(dispatch(toggleUserSettingsSection(query.expand)))
  }
  return Promise.all(actions)
})
@connect(({ people, userSettingsEditor, pending }) => ({
  pending: get(pending, `${UPLOAD_IMAGE}.subject`),
  currentUser: people.current,
  expand: {},
  ...userSettingsEditor
}))
export default class UserSettings extends React.Component {
  constructor (props) {
    super(props)
    this.state = {editing: {}, edited: {}, errors: {}}
  }

  static propTypes = {
    currentUser: object,
    dispatch: func,
    location: object,
    expand: object,
    pending: string
{'fraction_non_alphanumeric': 0.13863337713534823, 'fraction_numerical': 0.0, 'mean_word_length': 3.911290322580645, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '506248', 'n_tokens_mistral': 850, 'n_tokens_neox': 866, 'n_words': 241}