diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-07-31 13:03:20 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-08-24 07:44:44 +0800 |
commit | 5ee40675b9f986a9ff2e5d15a271d7de2145d0e9 (patch) | |
tree | 80f4b3e0a88a5621724a05efeb320596e0bcedad /ui/app/selectors | |
parent | d733bd34fbd356bca640b3a50582208c0284be40 (diff) | |
download | tangerine-wallet-browser-5ee40675b9f986a9ff2e5d15a271d7de2145d0e9.tar tangerine-wallet-browser-5ee40675b9f986a9ff2e5d15a271d7de2145d0e9.tar.gz tangerine-wallet-browser-5ee40675b9f986a9ff2e5d15a271d7de2145d0e9.tar.bz2 tangerine-wallet-browser-5ee40675b9f986a9ff2e5d15a271d7de2145d0e9.tar.lz tangerine-wallet-browser-5ee40675b9f986a9ff2e5d15a271d7de2145d0e9.tar.xz tangerine-wallet-browser-5ee40675b9f986a9ff2e5d15a271d7de2145d0e9.tar.zst tangerine-wallet-browser-5ee40675b9f986a9ff2e5d15a271d7de2145d0e9.zip |
Refactor transactions list views. Add redesign components
Diffstat (limited to 'ui/app/selectors')
-rw-r--r-- | ui/app/selectors/transactions.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ui/app/selectors/transactions.js b/ui/app/selectors/transactions.js new file mode 100644 index 000000000..a265b8e70 --- /dev/null +++ b/ui/app/selectors/transactions.js @@ -0,0 +1,50 @@ +import { createSelector } from 'reselect' +import { valuesFor } from '../util' +import { + UNAPPROVED_STATUS, + APPROVED_STATUS, + SUBMITTED_STATUS, +} from '../constants/transactions' + +export const shapeShiftTxListSelector = state => state.metamask.shapeShiftTxList +export const selectedTokenAddressSelector = state => state.metamask.selectedTokenAddress +export const unapprovedMsgsSelector = state => state.metamask.unapprovedMsgs +export const selectedAddressTxListSelector = state => state.metamask.selectedAddressTxList + +const pendingStatusHash = { + [UNAPPROVED_STATUS]: true, + [APPROVED_STATUS]: true, + [SUBMITTED_STATUS]: true, +} + +export 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) + } +) + +export const pendingTransactionsSelector = createSelector( + transactionsSelector, + (transactions = []) => ( + transactions.filter(transaction => transaction.status in pendingStatusHash) + ) +) + +export const completedTransactionsSelector = createSelector( + transactionsSelector, + (transactions = []) => ( + transactions.filter(transaction => !(transaction.status in pendingStatusHash)) + ) +) |