<commit_before>// @flow
import { take, call, put, select } from 'redux-saga/effects'
import {
  APP_FINISHED_LOADING,
  PERFORM_USER_LOGIN,
  PERFORM_USER_LOGOUT,
  USER_LOGGED_IN,
  USER_LOGGED_OUT
} from 'actions/types'

export default function* login(
  loginFunction: Function,
  logoutFunction: Function
): Generator<*, *, *> {
  yield take(APP_FINISHED_LOADING)
  let userIsLoggedIn = yield select(state => state.ui.userIsLoggedIn)

  while (true) {
    const action = yield take([
      USER_LOGGED_IN,
      PERFORM_USER_LOGIN,
      PERFORM_USER_LOGOUT
    ])
    if (action.type == PERFORM_USER_LOGIN) {
      if (!userIsLoggedIn) {
        yield call(loginFunction, action)
      }
    } else if (action.type == USER_LOGGED_IN) {<commit_msg>fix(flow): Fix flow errors in login saga.<commit_after>// @flow
import { take, call, put, select } from 'redux-saga/effects'
import {
  APP_FINISHED_LOADING,
  PERFORM_USER_LOGIN,
  PERFORM_USER_LOGOUT,
  USER_LOGGED_IN,
  USER_LOGGED_OUT
} from 'actions/types'

export default function* login(
  loginFunction: Function,
  logoutFunction: Function
): Generator<*, *, *> {
  yield take(APP_FINISHED_LOADING)
  let userIsLoggedIn: boolean = ((yield select(
    state => state.ui.userIsLoggedIn
  ): any): boolean)

  while (true) {
    const action = yield take([
      USER_LOGGED_IN,
      PERFORM_USER_LOGIN,
      PERFORM_USER_LOGOUT
    ])
    if (action.type == PERFORM_USER_LOGIN) {
      if (!userIsLoggedIn) {
        yield call(loginFunction, action)
      }
    } else if (action.type == USER_LOGGED_IN) {
{'fraction_non_alphanumeric': 0.10784939374601149, 'fraction_numerical': 0.0, 'mean_word_length': 3.680597014925373, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4001492', 'n_tokens_mistral': 577, 'n_tokens_neox': 558, 'n_words': 118}