From bfd13835f803bca70e6330ffea01f7122105d505 Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Sun, 22 Jul 2018 22:25:00 -0400 Subject: [PATCH] fix(transaction notification): fix that state access was off the mark And make the test more robust against unexpected state. --- app/reducers/transaction.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/reducers/transaction.js b/app/reducers/transaction.js index 3f65d025..28d4af81 100644 --- a/app/reducers/transaction.js +++ b/app/reducers/transaction.js @@ -123,7 +123,12 @@ export const transactionError = (event, { error }) => dispatch => { // Listener for when a new transaction is pushed from the subscriber export const newTransaction = (event, { transaction }) => (dispatch, getState) => { // add the transaction only if we are not already aware of it - if (!getState().transactions.find(tx => tx.tx_hash === transaction.tx_hash)) { + const state = getState() + if ( + !state.transaction || + !state.transaction.transactions || + !state.transaction.transactions.find(tx => tx.tx_hash === transaction.tx_hash) + ) { // Fetch new balance dispatch(fetchBalance())