<commit_before>import { USER_SIGN_IN_SUCCESS, USER_SIGN_IN_ERROR, USER_SIGN_OUT_SUCCESS, USER_SIGN_OUT_ERROR } from '../actions/user'

const initialState = {
  currentUser: null,
  loggedIn: false,
}

const user = (state = initialState, action) => {
  switch (action.type) {
    case USER_SIGN_IN_SUCCESS:
      return {
        currentUser: action.payload,
        loggedIn: true,
      }
    case USER_SIGN_IN_ERROR:
      console.log(`login failed:  ${action.payload}`)
      return state
    case USER_SIGN_OUT_SUCCESS:
      return initialState
    case USER_SIGN_OUT_ERROR:
    default:
      return state
  }
}

export default user
<commit_msg>Restore login state from server on page reload.<commit_after>import { USER_SIGN_IN_SUCCESS, USER_SIGN_IN_ERROR, USER_SIGN_OUT_SUCCESS, USER_SIGN_OUT_ERROR } from '../actions/user'

const initialState = {
  currentUser: Teikei.currentUser,
  loggedIn: !!Teikei.currentUser,
}

const user = (state = initialState, action) => {
  switch (action.type) {
    case USER_SIGN_IN_SUCCESS:
      return {
        currentUser: action.payload,
        loggedIn: true,
      }
    case USER_SIGN_IN_ERROR:
      console.log(`login failed:  ${action.payload}`)
      return state
    case USER_SIGN_OUT_SUCCESS:
      return {
        currentUser: null,
        loggedIn: false,
      }
    case USER_SIGN_OUT_ERROR:
    default:
      return state
  }
}

export default user

{'fraction_non_alphanumeric': 0.0884016973125884, 'fraction_numerical': 0.0, 'mean_word_length': 3.1374269005847952, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '339394', 'n_tokens_mistral': 465, 'n_tokens_neox': 484, 'n_words': 102}