From 356ef794f22de272b12cb84205da4fc8af463458 Mon Sep 17 00:00:00 2001 From: Jenny Pollack Date: Thu, 28 Mar 2019 19:18:53 -0700 Subject: prevent add duplicates when address is not new --- ui/app/components/app/send/send-footer/send-footer.container.js | 3 ++- ui/app/components/app/send/send-footer/send-footer.utils.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/app/components/app/send/send-footer/send-footer.container.js b/ui/app/components/app/send/send-footer/send-footer.container.js index 502159a81..ea3fd7ee4 100644 --- a/ui/app/components/app/send/send-footer/send-footer.container.js +++ b/ui/app/components/app/send/send-footer/send-footer.container.js @@ -96,9 +96,10 @@ function mapDispatchToProps (dispatch) { return dispatch(updateTransaction(editingTx)) }, + addToAddressBookIfNew: (newAddress, toAccounts, nickname = '') => { const hexPrefixedAddress = ethUtil.addHexPrefix(newAddress) - if (addressIsNew(toAccounts)) { + if (addressIsNew(toAccounts, hexPrefixedAddress)) { // TODO: nickname, i.e. addToAddressBook(recipient, nickname) dispatch(addToAddressBook(hexPrefixedAddress, nickname)) } diff --git a/ui/app/components/app/send/send-footer/send-footer.utils.js b/ui/app/components/app/send/send-footer/send-footer.utils.js index f82ff1e9b..a63316336 100644 --- a/ui/app/components/app/send/send-footer/send-footer.utils.js +++ b/ui/app/components/app/send/send-footer/send-footer.utils.js @@ -74,7 +74,7 @@ function constructUpdatedTx ({ } function addressIsNew (toAccounts, newAddress) { - return !toAccounts.find(({ address }) => newAddress === address) + return !toAccounts.find(({ address }) => (newAddress === address || newAddress.toLowerCase() === address)) } module.exports = { -- cgit v1.2.3 From 0961449ca05e48c82961b58cce2b6ad5ca32714e Mon Sep 17 00:00:00 2001 From: kumavis Date: Fri, 29 Mar 2019 13:34:49 +0800 Subject: send-footer.utils.js - addressIsNew - improve readability --- ui/app/components/app/send/send-footer/send-footer.utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/app/components/app/send/send-footer/send-footer.utils.js b/ui/app/components/app/send/send-footer/send-footer.utils.js index a63316336..abb2ebc77 100644 --- a/ui/app/components/app/send/send-footer/send-footer.utils.js +++ b/ui/app/components/app/send/send-footer/send-footer.utils.js @@ -74,7 +74,9 @@ function constructUpdatedTx ({ } function addressIsNew (toAccounts, newAddress) { - return !toAccounts.find(({ address }) => (newAddress === address || newAddress.toLowerCase() === address)) + const newAddressNormalized = newAddress.toLowerCase() + const foundMatching = toAccounts.some(({ address }) => address === newAddressNormalized) + return !foundMatching } module.exports = { -- cgit v1.2.3