Commit e4473e30 authored by lynn's avatar lynn Committed by GitHub

fix: use same loader in view my nfts as collection (#5428)

* loader

* fix
parent da2f168e
...@@ -127,7 +127,7 @@ export const ClearAllButton = styled.button` ...@@ -127,7 +127,7 @@ export const ClearAllButton = styled.button`
background: none; background: none;
` `
const InfiniteScrollWrapper = styled.div` export const InfiniteScrollWrapper = styled.div`
${InfiniteScrollWrapperCss} ${InfiniteScrollWrapperCss}
` `
...@@ -168,9 +168,9 @@ const MarketNameWrapper = styled(Row)` ...@@ -168,9 +168,9 @@ const MarketNameWrapper = styled(Row)`
gap: 8px; gap: 8px;
` `
const LoadingAssets = () => ( export const LoadingAssets = ({ count }: { count?: number }) => (
<> <>
{Array.from(Array(ASSET_PAGE_SIZE), (_, index) => ( {Array.from(Array(count ?? ASSET_PAGE_SIZE), (_, index) => (
<CollectionAssetLoading key={index} /> <CollectionAssetLoading key={index} />
))} ))}
</> </>
......
import { useNftBalanceQuery } from 'graphql/data/nft/NftBalance' import { useNftBalanceQuery } from 'graphql/data/nft/NftBalance'
import { AnimatedBox, Box } from 'nft/components/Box' import { AnimatedBox, Box } from 'nft/components/Box'
import { ClearAllButton } from 'nft/components/collection/CollectionNfts' import { ClearAllButton, LoadingAssets } from 'nft/components/collection/CollectionNfts'
import { assetList } from 'nft/components/collection/CollectionNfts.css' import { assetList } from 'nft/components/collection/CollectionNfts.css'
import { FilterButton } from 'nft/components/collection/FilterButton' import { FilterButton } from 'nft/components/collection/FilterButton'
import { LoadingSparkle } from 'nft/components/common/Loading/LoadingSparkle' import { Column, Row } from 'nft/components/Flex'
import { Center, Column, Row } from 'nft/components/Flex'
import { CrossIcon } from 'nft/components/icons' import { CrossIcon } from 'nft/components/icons'
import { FilterSidebar } from 'nft/components/profile/view/FilterSidebar' import { FilterSidebar } from 'nft/components/profile/view/FilterSidebar'
import { subhead } from 'nft/css/common.css' import { subhead } from 'nft/css/common.css'
...@@ -201,6 +200,7 @@ const ProfilePageNfts = ({ ...@@ -201,6 +200,7 @@ const ProfilePageNfts = ({
walletAssets: ownerAssets, walletAssets: ownerAssets,
loadNext, loadNext,
hasNext, hasNext,
isLoadingNext,
} = useNftBalanceQuery(address, collectionFilters, [], DEFAULT_WALLET_ASSET_QUERY_AMOUNT) } = useNftBalanceQuery(address, collectionFilters, [], DEFAULT_WALLET_ASSET_QUERY_AMOUNT)
const { gridX } = useSpring({ const { gridX } = useSpring({
...@@ -245,27 +245,24 @@ const ProfilePageNfts = ({ ...@@ -245,27 +245,24 @@ const ProfilePageNfts = ({
next={() => loadNext(DEFAULT_WALLET_ASSET_QUERY_AMOUNT)} next={() => loadNext(DEFAULT_WALLET_ASSET_QUERY_AMOUNT)}
hasMore={hasNext} hasMore={hasNext}
loader={ loader={
<Center> Boolean(hasNext && ownerAssets?.length) && <LoadingAssets count={DEFAULT_WALLET_ASSET_QUERY_AMOUNT} />
<LoadingSparkle />
</Center>
} }
dataLength={ownerAssets?.length ?? 0} dataLength={ownerAssets?.length ?? 0}
className={ownerAssets?.length || isLoadingNext ? assetList : undefined}
style={{ overflow: 'unset' }} style={{ overflow: 'unset' }}
> >
<div className={assetList}> {ownerAssets?.length
{ownerAssets?.length ? ownerAssets.map((asset, index) => (
? ownerAssets.map((asset, index) => ( <div key={index}>
<div key={index}> <ViewMyNftsAsset
<ViewMyNftsAsset asset={asset}
asset={asset} mediaShouldBePlaying={asset.tokenId === currentTokenPlayingMedia}
mediaShouldBePlaying={asset.tokenId === currentTokenPlayingMedia} setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia}
setCurrentTokenPlayingMedia={setCurrentTokenPlayingMedia} hideDetails={sellAssets.length > 0}
hideDetails={sellAssets.length > 0} />
/> </div>
</div> ))
)) : null}
: null}
</div>
</InfiniteScroll> </InfiniteScroll>
</AnimatedBox> </AnimatedBox>
)} )}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment