diff options
Diffstat (limited to 'ui/app/selectors.js')
-rw-r--r-- | ui/app/selectors.js | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/ui/app/selectors.js b/ui/app/selectors.js index d86462275..1b0100297 100644 --- a/ui/app/selectors.js +++ b/ui/app/selectors.js @@ -1,5 +1,9 @@ -const valuesFor = require('./util').valuesFor const abi = require('human-standard-token-abi') +import { createSelector } from 'reselect' + +import { + transactionsSelector, +} from './selectors/transactions' const { multiplyCurrencies, @@ -101,21 +105,49 @@ function getCurrentAccountWithSendEtherInfo (state) { return accounts.find(({ address }) => address === currentAddress) } -function transactionsSelector (state) { - const { network, selectedTokenAddress } = state.metamask - const unapprovedMsgs = valuesFor(state.metamask.unapprovedMsgs) - const shapeShiftTxList = (network === '1') ? state.metamask.shapeShiftTxList : undefined - const transactions = state.metamask.selectedAddressTxList || [] - const txsToRender = !shapeShiftTxList ? transactions.concat(unapprovedMsgs) : transactions.concat(unapprovedMsgs, shapeShiftTxList) +// // function shapeShiftTxListSelector (state) { +// // return state.metamask.shapeShiftTxList || [] +// // } + +// const transactionsSelector = createSelector( +// selectedTokenAddressSelector, +// unapprovedMsgsSelector, +// shapeShiftTxListSelector, +// selectedAddressTxListSelector, +// (selectedTokenAddress, unapprovedMsgs = {}, shapeShiftTxList = [], transactions = []) => { +// const unapprovedMsgsList = valuesFor(unapprovedMsgs) +// const txsToRender = transactions.concat(unapprovedMsgsList, shapeShiftTxList) + +// return selectedTokenAddress +// ? txsToRender +// .filter(({ txParams }) => txParams && txParams.to === selectedTokenAddress) +// .sort((a, b) => b.time - a.time) +// : txsToRender +// .sort((a, b) => b.time - a.time) +// } +// ) + +// // function transactionsSelector (state) { +// // const { selectedTokenAddress } = state.metamask +// // const unapprovedMsgs = valuesFor(state.metamask.unapprovedMsgs) +// // const shapeShiftTxList = shapeShiftTxListSelector(state) +// // const transactions = state.metamask.selectedAddressTxList || [] +// // const txsToRender = transactions.concat(unapprovedMsgs, shapeShiftTxList) + +// // return selectedTokenAddress +// // ? txsToRender +// // .filter(({ txParams }) => txParams && txParams.to === selectedTokenAddress) +// // .sort((a, b) => b.time - a.time) +// // : txsToRender +// // .sort((a, b) => b.time - a.time) +// // } + +export const pendingTransactionsSelector = createSelector( + transactionsSelector, + transactions => { - // console.log({txsToRender, selectedTokenAddress}) - return selectedTokenAddress - ? txsToRender - .filter(({ txParams }) => txParams && txParams.to === selectedTokenAddress) - .sort((a, b) => b.time - a.time) - : txsToRender - .sort((a, b) => b.time - a.time) -} + } +) function getGasIsLoading (state) { return state.appState.gasIsLoading |