aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2019-04-12 08:03:33 +0800
committerWhymarrh Whitby <whymarrh.whitby@gmail.com>2019-04-12 08:20:06 +0800
commitc4a3d4ea82ef5488c8c91db77beca85679447722 (patch)
tree510ab68434b7637e01fa83c569bbc327a3630703
parent2786932576a92f8e75ee798d91c8222741c774c9 (diff)
downloadtangerine-wallet-browser-c4a3d4ea82ef5488c8c91db77beca85679447722.tar
tangerine-wallet-browser-c4a3d4ea82ef5488c8c91db77beca85679447722.tar.gz
tangerine-wallet-browser-c4a3d4ea82ef5488c8c91db77beca85679447722.tar.bz2
tangerine-wallet-browser-c4a3d4ea82ef5488c8c91db77beca85679447722.tar.lz
tangerine-wallet-browser-c4a3d4ea82ef5488c8c91db77beca85679447722.tar.xz
tangerine-wallet-browser-c4a3d4ea82ef5488c8c91db77beca85679447722.tar.zst
tangerine-wallet-browser-c4a3d4ea82ef5488c8c91db77beca85679447722.zip
Remove unneeded array cloning in getSendToAccounts selector
The use of `Object.entries` here to map the accounts into a new array effectively produces a shallow clone of the array without guaranteeing the order of the original array (as object iteration order is implementation-specific and variable). From MDN [1]: > The **`Object.entries()`** method returns an array of a given object's own enumerable > string-keyed property `[key, value]` pairs, in the same order as that provided by a > `for...in` loop And also: > The ordering of the properties is the same as that given by looping over the > property values of the object manually. Both of which suggest that the iteration order is the same as `for...in`, which is to say that it's not specified. [2] [3] This changeset removes the cloning, keeping the shallow clone created the line before which preserves the order of the items in the array. [1]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries [2]:https://stackoverflow.com/a/5525820/1267663 [3]:https://stackoverflow.com/a/30919039/1267663
-rw-r--r--ui/app/components/app/send/send.selectors.js4
1 files changed, 1 insertions, 3 deletions
diff --git a/ui/app/components/app/send/send.selectors.js b/ui/app/components/app/send/send.selectors.js
index 89f047d50..6056dea21 100644
--- a/ui/app/components/app/send/send.selectors.js
+++ b/ui/app/components/app/send/send.selectors.js
@@ -240,9 +240,7 @@ function getSendTo (state) {
function getSendToAccounts (state) {
const fromAccounts = accountsWithSendEtherInfoSelector(state)
const addressBookAccounts = getAddressBook(state)
- const allAccounts = [...fromAccounts, ...addressBookAccounts]
- // TODO: figure out exactly what the below returns and put a descriptive variable name on it
- return Object.entries(allAccounts).map(([key, account]) => account)
+ return [...fromAccounts, ...addressBookAccounts]
}
function getSendWarnings (state) {