<commit_before>import { takeLatest, call, put } from 'redux-saga/effects';
import { push } from 'react-router-redux';
import { gql } from 'react-apollo';

import { bootstrap } from '../../utils/sagas';
import { CHANGE_PASSWORD } from './constants';
import { profilePage } from '../../local-urls';
import { changePasswordError, changePasswordSuccess } from './actions';
import { client } from '../../graphql';


const ChangePasswordMutation = gql`
  mutation ChangePasswordMutation($oldPassword: String!, $newPassword: String!){
    changePassword(oldPassword: $oldPassword, newPassword: $newPassword)
  }
`;

function sendPasswordChange(oldPassword, newPassword) {
  return client.mutate({ mutation: ChangePasswordMutation, variables: { oldPassword, newPassword } });
}

function* changePassword({ oldPassword, newPassword, from = profilePage() }) {
  try {
    const response = yield call(sendPasswordChange, oldPassword, newPassword);
    yield put(response.data.changePassword.changed === true ? changePasswordSuccess() : changePasswordError());
    yield put(push(from));
  } catch (e) {
    yield put(changePasswordError());
  }
}

function* changePasswordSaga() {
  yield takeLatest(CHANGE_PASSWORD, changePassword);
}

export default bootstrap([
  changePasswordSaga,
]);<commit_msg>Do not redirect on password change<commit_after>import { takeLatest, call, put } from 'redux-saga/effects';
import { gql } from 'react-apollo';

import { bootstrap } from '../../utils/sagas';
import { CHANGE_PASSWORD } from './constants';
import { changePasswordError, changePasswordSuccess } from './actions';
import { client } from '../../graphql';

const ChangePasswordMutation = gql`
  mutation ChangePasswordMutation($oldPassword: String!, $newPassword: String!){
    changePassword(oldPassword: $oldPassword, newPassword: $newPassword)
  }
`;

function sendPasswordChange(oldPassword, newPassword) {
  return client.mutate({ mutation: ChangePasswordMutation, variables: { oldPassword, newPassword } });
}

function* changePassword({ oldPassword, newPassword }) {
  try {
    const response = yield call(sendPasswordChange, oldPassword, newPassword);
    yield put(response.data.changePassword.changed === true ? changePasswordSuccess() : changePasswordError());
  } catch (e) {
    yield put(changePasswordError());
  }
}

function* changePasswordSaga() {
  yield takeLatest(CHANGE_PASSWORD, changePassword);
}

export default bootstrap([
  changePasswordSaga,
]);
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.0, 'mean_word_length': 5.4255874673629245, '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': '229404', 'n_tokens_mistral': 692, 'n_tokens_neox': 688, 'n_words': 173}