Commit 7512b670 authored by Benjamin Bouvier's avatar Benjamin Bouvier
Browse files

Fixes #572: Reload accounts/operations after updating account parameters;

On the server, updating the account triggers an accounts/operations fetch. The
fetch results were sent to the client, but never handled there. This fixes it.
parent 9e454597
......@@ -29,13 +29,13 @@ import {
DELETE_OPERATION,
MERGE_OPERATIONS,
SET_ACCOUNT_ID,
SET_OPERATION_CUSTOM_LABEL,
SET_OPERATION_CATEGORY,
SET_OPERATION_CUSTOM_LABEL,
SET_OPERATION_TYPE,
RUN_ACCOUNTS_SYNC,
RUN_BALANCE_RESYNC,
RUN_SYNC,
UPDATE_ALERT,
RUN_BALANCE_RESYNC
UPDATE_ALERT
} from './actions';
import StaticBanks from '../../shared/banks.json';
......@@ -849,7 +849,16 @@ function reduceCreateAccess(state, action) {
}
debug('Creating access...');
return u({ processingReason: $t('client.spinner.create_account') }, state);
return u({ processingReason: $t('client.spinner.fetch_account') }, state);
}
function reduceUpdateAccess(state, action) {
if (action.status !== SUCCESS) {
return state;
}
assertHas(action, 'results');
return finishSync(state, action.results);
}
function reduceCreateAlert(state, action) {
......@@ -952,7 +961,8 @@ const reducers = {
SET_OPERATION_CATEGORY: reduceSetOperationCategory,
SET_OPERATION_CUSTOM_LABEL: reduceSetOperationCustomLabel,
SET_OPERATION_TYPE: reduceSetOperationType,
UPDATE_ALERT: reduceUpdateAlert
UPDATE_ALERT: reduceUpdateAlert,
UPDATE_ACCESS: reduceUpdateAccess
};
export const reducer = createReducerFromMap(bankState, reducers);
......
......@@ -52,9 +52,10 @@ const basic = {
};
},
updateAccess() {
updateAccess(results = {}) {
return {
type: UPDATE_ACCESS
type: UPDATE_ACCESS,
results
};
},
......@@ -126,8 +127,9 @@ export function updateWeboob() {
export function updateAccess(accessId, login, password, customFields) {
return dispatch => {
dispatch(basic.updateAccess());
backend.updateAccess(accessId, { login, password, customFields }).then(() => {
dispatch(success.updateAccess());
backend.updateAccess(accessId, { login, password, customFields }).then(results => {
results.accessId = accessId;
dispatch(success.updateAccess(results));
}).catch(err => {
dispatch(fail.updateAccess(err));
});
......@@ -243,16 +245,16 @@ function reduceUpdateAccess(state, action) {
if (status === SUCCESS) {
debug('Successfully updated access');
// Nothing to do yet: accesses are not locally saved.
return state;
return u({ processingReason: null }, state);
}
if (status === FAIL) {
debug('Error when updating access', action.error);
return state;
return u({ processingReason: null }, state);
}
debug('Updating access...');
return state;
return u({ processingReason: $t('client.spinner.fetch_account') }, state);
}
function reduceImportInstance(state, action) {
......
......@@ -420,9 +420,9 @@ module.exports = {
},
spinner: {
title: "Please wait...",
title: "Please wait",
balance_resync: "Resynchronizing your account's balance…",
create_account: "Connecting to your bank's website and fetching all the accounts and transactions…",
fetch_account: "Connecting to your bank's website and fetching all the accounts and transactions…",
delete_account: "Deleting your account and associated data from Kresus…",
generic: "Kresus is processing your demand, hang tight!",
import: 'Importing your backup data into Kresus…',
......
......@@ -422,7 +422,7 @@ module.exports = {
spinner: {
title: "Veuillez patienter…",
balance_resync: "Resynchronisation de votre balance en cours…",
create_account: "Connexion au site de votre banque et import des comptes et opérations en cours…",
fetch_account: "Connexion au site de votre banque et import des comptes et opérations en cours…",
delete_account: "Suppression de votre compte et des données associées en cours…",
generic: "Kresus est en train d'exécuter vos souhaits, à tout de suite !",
import: 'Import de votre instance sauvegardée en cours…',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment