1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-28 09:58:23 +00:00

Review implemented

This commit is contained in:
Vladimir Volek 2018-11-12 10:36:40 +01:00
parent 9844983e09
commit 8e13b49d2e
2 changed files with 16 additions and 5 deletions

View File

@ -14,10 +14,21 @@ export const initialState: Array<Fiat> = [];
const update = (state: Array<Fiat>, action: FiatRateAction): Array<Fiat> => {
const newState: Array<Fiat> = [...state];
newState.push({
network: action.network,
value: action.rate.current_price.usd,
});
let exists: ?Fiat = newState.find(f => f.network === action.network);
const { network, rate } = action;
if (exists) {
exists = {
network,
value: rate,
};
} else {
newState.push({
network,
value: rate,
});
}
return newState;
};

View File

@ -33,7 +33,7 @@ const loadRateAction = (): AsyncAction => async (dispatch: Dispatch, getState: G
dispatch({
type: RATE_UPDATE,
network: response.symbol,
rate: response.market_data,
rate: response.market_data.current_price.usd,
});
}
});