Uses orderedNFTAssets (#1546)

Co-authored-by: Daniel Sanchez <daniel.sanchez@gnosis.pm>
This commit is contained in:
Agustin Pane 2020-11-02 09:27:49 -03:00 committed by GitHub
parent 9fea501e4e
commit cd8dc8d486
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import { createSelector } from 'reselect'
import { NFTAsset, NFTAssets, NFTTokens } from 'src/logic/collectibles/sources/collectibles.d'
import { NFTAsset, NFTAssets, NFTToken, NFTTokens } from 'src/logic/collectibles/sources/collectibles.d'
import { AppReduxState } from 'src/store'
import { NFT_ASSETS_REDUCER_ID, NFT_TOKENS_REDUCER_ID } from 'src/logic/collectibles/store/reducer/collectibles'
@ -20,6 +20,10 @@ export const availableNftAssetsAddresses = createSelector(nftTokensSelector, (us
return Array.from(new Set(userNftTokens.map((nftToken) => nftToken.assetAddress)))
})
export const orderedNFTAssets = createSelector(nftTokensSelector, (userNftTokens): NFTToken[] =>
userNftTokens.sort((a, b) => a.name.localeCompare(b.name)),
)
export const activeNftAssetsListSelector = createSelector(
nftAssetsListSelector,
safeActiveAssetsSelector,

View File

@ -6,7 +6,7 @@ import { useSelector } from 'react-redux'
import Item from './components/Item'
import Paragraph from 'src/components/layout/Paragraph'
import { activeNftAssetsListSelector, nftTokensSelector } from 'src/logic/collectibles/store/selectors'
import { activeNftAssetsListSelector, orderedNFTAssets } from 'src/logic/collectibles/store/selectors'
import SendModal from 'src/routes/safe/components/Balances/SendModal'
import { fontColor, lg, screenSm, screenXs } from 'src/theme/variables'
import { useAnalytics, SAFE_NAVIGATION_EVENT } from 'src/utils/googleAnalytics'
@ -81,7 +81,7 @@ const Collectibles = (): React.ReactElement => {
const classes = useStyles()
const [selectedToken, setSelectedToken] = React.useState<NFTToken | undefined>()
const [sendNFTsModalOpen, setSendNFTsModalOpen] = React.useState(false)
const nftTokens = useSelector(nftTokensSelector)
const nftTokens = useSelector(orderedNFTAssets)
const activeAssetsList = useSelector(activeNftAssetsListSelector)
const { trackEvent } = useAnalytics()