Browse Source

Only ADD_TRANSACTION if we are not already tracking the transaction

LND’s SubscribeTransactions will announce transactions multiple times.
I haven’t looked into which circumstances this occur, but an easy fix
is to filter out the incoming transactions that we already have on record.

Fixes #317
renovate/lint-staged-8.x
Ben Woosley 7 years ago
parent
commit
2ade0a7a45
No known key found for this signature in database GPG Key ID: 4D8CA4BA18040906
  1. 8
      app/reducers/transaction.js

8
app/reducers/transaction.js

@ -105,7 +105,13 @@ const ACTION_HANDLERS = {
[RECEIVE_TRANSACTIONS]: (state, { transactions }) => ({ ...state, transactionLoading: false, transactions }),
[TRANSACTION_SUCCESSFULL]: state => ({ ...state, sendingTransaction: false }),
[TRANSACTION_FAILED]: state => ({ ...state, sendingTransaction: false }),
[ADD_TRANSACTION]: (state, { transaction }) => ({ ...state, transactions: [transaction, ...state.transactions] })
[ADD_TRANSACTION]: (state, { transaction }) => (
// add the transaction only if we are not already aware of it
state.transactions.find(tx => (tx.tx_hash === transaction.tx_hash)) ? state : {
...state,
transactions: [transaction, ...state.transactions]
}
)
}
// ------------------------------------

Loading…
Cancel
Save