<commit_before>/* eslint-disable no-constant-condition */
import { fork, put, select, take } from 'redux-saga/effects'
import { registerForGCM, unregisterForGCM } from '../actions/profile'
import { AUTHENTICATION, PROFILE } from '../constants/action_types'
import {
  bundleIdSelector,
  isLoggedInSelector,
  registrationIdSelector,
} from './selectors'

export function* loginPushSubscribe() {
  while (true) {
    const action = yield take(PROFILE.REQUEST_PUSH_SUBSCRIPTION)
    const { buildVersion, bundleId, marketingVersion, registrationId } = action.payload
    if (yield select(isLoggedInSelector)) {
      yield put(registerForGCM(registrationId, bundleId, marketingVersion, buildVersion))
    } else {
      yield take(AUTHENTICATION.USER_SUCCESS)
      yield put(registerForGCM(registrationId, bundleId, marketingVersion, buildVersion))
    }
  }
}

export function* logoutPushUnsubscribe() {
  while (true) {
    yield take([AUTHENTICATION.LOGOUT, PROFILE.DELETE])
    const registrationId = yield select(registrationIdSelector)
    const bundleId = yield select(bundleIdSelector)
    yield put(unregisterForGCM(registrationId, bundleId))
  }
}

export default function* pushSubscription() {
  yield [
    fork(loginPushSubscribe),
    fork(logoutPushUnsubscribe),
  ]
}
<commit_msg>Moves the while check to the main generator.<commit_after>/* eslint-disable no-constant-condition */
import { fork, put, select, take } from 'redux-saga/effects'
import { registerForGCM, unregisterForGCM } from '../actions/profile'
import { AUTHENTICATION, PROFILE } from '../constants/action_types'
import {
  bundleIdSelector,
  isLoggedInSelector,
  registrationIdSelector,
} from './selectors'

export function* loginPushSubscribe() {
  const action = yield take(PROFILE.REQUEST_PUSH_SUBSCRIPTION)
  const { buildVersion, bundleId, marketingVersion, registrationId } = action.payload
  if (yield select(isLoggedInSelector)) {
    yield put(registerForGCM(registrationId, bundleId, marketingVersion, buildVersion))
  } else {
    yield take(AUTHENTICATION.USER_SUCCESS)
    yield put(registerForGCM(registrationId, bundleId, marketingVersion, buildVersion))
  }
}

export function* logoutPushUnsubscribe() {
  yield take([AUTHENTICATION.LOGOUT, PROFILE.DELETE])
  const registrationId = yield select(registrationIdSelector)
  const bundleId = yield select(bundleIdSelector)
  yield put(unregisterForGCM(registrationId, bundleId))
}

export default function* pushSubscription() {
  while (true) {
    yield [
      fork(loginPushSubscribe),
      fork(logoutPushUnsubscribe),
    ]
  }
}

{'fraction_non_alphanumeric': 0.10015467904098994, 'fraction_numerical': 0.0, 'mean_word_length': 5.115839243498818, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2244658', 'n_tokens_mistral': 757, 'n_tokens_neox': 748, 'n_words': 171}