From 10a144ce640d3a5bf9fe8e684a0bd4bf62bc136a Mon Sep 17 00:00:00 2001 From: apanizo Date: Thu, 16 Aug 2018 11:15:57 +0200 Subject: [PATCH] WA-521 Fetch transactions only retrieve tx-history data from one safe --- .../safe/store/actions/fetchTransactions.js | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/routes/safe/store/actions/fetchTransactions.js b/src/routes/safe/store/actions/fetchTransactions.js index c03b460f..c4850c3d 100644 --- a/src/routes/safe/store/actions/fetchTransactions.js +++ b/src/routes/safe/store/actions/fetchTransactions.js @@ -44,33 +44,23 @@ const buildTransactionFrom = (tx: TxServiceModel, safeSubjects: Map { - const safes = load(TX_KEY) || {} - const safeAddresses: string[] = Object.keys(safes) - const transactions: TxServiceModel[][] = await Promise.all(safeAddresses.map(async (safeAddress: string) => { - const url = buildTxServiceUrlFrom(safeAddress) +export const loadSafeTransactions = async (safeAddress: string) => { + const url = buildTxServiceUrlFrom(safeAddress) + const response = await enhancedFetch(url, 'Error fetching txs information') + const transactions: TxServiceModel[] = response.results + const safeSubjects = loadSafeSubjects(safeAddress) + const txsRecord = transactions.map((tx: TxServiceModel) => buildTransactionFrom(tx, safeSubjects)) - return enhancedFetch(url, 'Error fetching txs information') - })) - - return Map().withMutations((map: Map>) => { - transactions.map((safeTxs: TxServiceModel[], index) => { - const safeAddress = safeAddresses[index] - const safeSubjects = loadSafeSubjects(safeAddress) - const txsRecord = safeTxs.map((tx: TxServiceModel) => buildTransactionFrom(tx, safeSubjects)) - - return map.set(safeAddress, List(txsRecord)) - }) - }) + return Map().set(safeAddress, List(txsRecord)) } -export default () => async (dispatch: ReduxDispatch) => { - const transactions: Map> = await loadSafeTransactions() +export default (safeAddress: string) => async (dispatch: ReduxDispatch) => { + const transactions: Map> = await loadSafeTransactions(safeAddress) return dispatch(addTransactions(transactions)) }