(Bug) - #1503 Fix collectibles groups is not removed when the last item from it is sent (#1511)

* Remove default export with const

* Filter collectibles group with user's available nftAsset

* Improves filter

* Fix duplicated assets
This commit is contained in:
Agustin Pane 2020-10-26 10:58:01 -03:00 committed by GitHub
parent 058fec3dbc
commit 4ce8917f34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions

View File

@ -4,7 +4,7 @@ import { Dispatch } from 'redux'
import { getConfiguredSource } from 'src/logic/collectibles/sources'
import { addNftAssets, addNftTokens } from 'src/logic/collectibles/store/actions/addCollectibles'
const fetchCollectibles = (safeAddress: string) => async (dispatch: Dispatch): Promise<void> => {
export const fetchCollectibles = (safeAddress: string) => async (dispatch: Dispatch): Promise<void> => {
try {
const source = getConfiguredSource()
const collectibles = await source.fetchCollectibles(safeAddress)
@ -17,5 +17,3 @@ const fetchCollectibles = (safeAddress: string) => async (dispatch: Dispatch): P
console.log('Error fetching collectibles:', error)
}
}
export default fetchCollectibles

View File

@ -16,11 +16,18 @@ export const nftAssetsListSelector = createSelector(nftAssets, (assets): NFTAsse
return assets ? Object.values(assets) : []
})
export const availableNftAssetsAddresses = createSelector(nftTokensSelector, (userNftTokens): string[] => {
return Array.from(new Set(userNftTokens.map((nftToken) => nftToken.assetAddress)))
})
export const activeNftAssetsListSelector = createSelector(
nftAssetsListSelector,
safeActiveAssetsSelector,
(assets, activeAssetsList): NFTAsset[] => {
return assets.filter(({ address }) => activeAssetsList.has(address))
availableNftAssetsAddresses,
(assets, activeAssetsList, availableNftAssetsAddresses): NFTAsset[] => {
return assets
.filter(({ address }) => activeAssetsList.has(address))
.filter(({ address }) => availableNftAssetsAddresses.includes(address))
},
)

View File

@ -2,7 +2,7 @@ import { useMemo } from 'react'
import { batch, useDispatch } from 'react-redux'
import { useLocation } from 'react-router-dom'
import fetchCollectibles from 'src/logic/collectibles/store/actions/fetchCollectibles'
import { fetchCollectibles } from 'src/logic/collectibles/store/actions/fetchCollectibles'
import { fetchSelectedCurrency } from 'src/logic/currencyValues/store/actions/fetchSelectedCurrency'
import activateAssetsByBalance from 'src/logic/tokens/store/actions/activateAssetsByBalance'
import fetchSafeTokens from 'src/logic/tokens/store/actions/fetchSafeTokens'

View File

@ -1,7 +1,7 @@
import { useEffect, useRef } from 'react'
import { batch, useDispatch } from 'react-redux'
import fetchCollectibles from 'src/logic/collectibles/store/actions/fetchCollectibles'
import { fetchCollectibles } from 'src/logic/collectibles/store/actions/fetchCollectibles'
import fetchSafeTokens from 'src/logic/tokens/store/actions/fetchSafeTokens'
import fetchEtherBalance from 'src/logic/safe/store/actions/fetchEtherBalance'
import { checkAndUpdateSafe } from 'src/logic/safe/store/actions/fetchSafe'