Browse Source

Merge pull request #574 from mrfelton/fix/transaction-received

fix: ensure received transactions show as such
renovate/lint-staged-8.x
Ben Woosley 7 years ago
committed by GitHub
parent
commit
20d1e3502e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      app/reducers/transaction.js

15
app/reducers/transaction.js

@ -23,6 +23,16 @@ export const ADD_TRANSACTION = 'ADD_TRANSACTION'
export const SHOW_SUCCESS_TRANSACTION_SCREEN = 'SHOW_SUCCESS_TRANSACTION_SCREEN'
export const HIDE_SUCCESS_TRANSACTION_SCREEN = 'HIDE_SUCCESS_TRANSACTION_SCREEN'
// ------------------------------------
// Helpers
// ------------------------------------
// Decorate transaction object with custom/computed properties.
const decorateTransaction = transaction => {
transaction.received = transaction.amount > 0
return transaction
}
// ------------------------------------
// Actions
// ------------------------------------
@ -66,6 +76,7 @@ export const receiveTransactions = (event, { transactions }) => (dispatch, getSt
const currentAddress = state.address.address
let usedAddresses = []
transactions.forEach(transaction => {
decorateTransaction(transaction)
usedAddresses = usedAddresses.concat(transaction.dest_addresses)
})
if (usedAddresses.includes(currentAddress)) {
@ -114,9 +125,9 @@ export const newTransaction = (event, { transaction }) => dispatch => {
// Fetch new balance
dispatch(fetchBalance())
dispatch({ type: ADD_TRANSACTION, transaction })
decorateTransaction(transaction)
transaction.received = transaction.amount > 0
dispatch({ type: ADD_TRANSACTION, transaction })
// HTML 5 desktop notification for the new transaction
const notifTitle = transaction.received

Loading…
Cancel
Save