remove List from selectors

This commit is contained in:
fernandomg 2020-07-17 17:33:21 -03:00
parent 46e567ba88
commit c28124b685
3 changed files with 11 additions and 18 deletions

View File

@ -1,4 +1,3 @@
import { List } from 'immutable'
import { createSelector } from 'reselect'
import { NFTAsset, NFTAssets, NFTTokens } from 'src/logic/collectibles/sources/OpenSea'
@ -9,17 +8,14 @@ import { safeActiveAssetsSelector } from 'src/routes/safe/store/selectors'
export const nftAssetsSelector = (state: AppReduxState): NFTAssets => state[NFT_ASSETS_REDUCER_ID]
export const nftTokensSelector = (state: AppReduxState): NFTTokens => state[NFT_TOKENS_REDUCER_ID]
export const nftAssetsListSelector = createSelector(
nftAssetsSelector,
(assets): List<NFTAsset> => {
return assets ? List(Object.values(assets)) : List()
},
)
export const nftAssetsListSelector = createSelector(nftAssetsSelector, (assets): NFTAsset[] => {
return assets ? Object.values(assets) : []
})
export const activeNftAssetsListSelector = createSelector(
nftAssetsListSelector,
safeActiveAssetsSelector,
(assets, activeAssetsList): List<NFTAsset> => {
(assets, activeAssetsList): NFTAsset[] => {
return assets.filter(({ address }) => activeAssetsList.has(address))
},
)
@ -27,12 +23,9 @@ export const activeNftAssetsListSelector = createSelector(
export const safeActiveSelectorMap = createSelector(
activeNftAssetsListSelector,
(activeAssets): NFTAssets => {
const assetsMap = {}
activeAssets.forEach((asset) => {
assetsMap[asset.address] = asset
})
return assetsMap
return activeAssets.reduce((acc, asset) => {
acc[asset.address] = asset
return acc
}, {})
},
)

View File

@ -90,7 +90,7 @@ const Collectibles = () => {
return (
<Card className={classes.cardOuter}>
<div className={classes.cardInner}>
{activeAssetsList.size ? (
{activeAssetsList.length ? (
activeAssetsList.map((nftAsset) => {
return (
<React.Fragment key={nftAsset.slug}>

View File

@ -130,12 +130,12 @@ const AssetsList = (props) => {
</Row>
<Hairline />
</Block>
{!nftAssetsList.size && (
{!nftAssetsList.length && (
<Block className={classes.progressContainer} justify="center">
<CircularProgress />
</Block>
)}
{nftAssetsList.size > 0 && (
{nftAssetsList.length > 0 && (
<MuiList className={classes.list}>
<FixedSizeList
height={413}