fix: hide collection search for > 300 collections due to lack of search param input for OS api (#5383)
* init * fix * respond to charlie
This commit is contained in:
parent
875171e36a
commit
0b40f72f0c
@ -10,7 +10,17 @@ import { subhead } from 'nft/css/common.css'
|
|||||||
import { themeVars } from 'nft/css/sprinkles.css'
|
import { themeVars } from 'nft/css/sprinkles.css'
|
||||||
import { useFiltersExpanded, useIsMobile, useWalletCollections } from 'nft/hooks'
|
import { useFiltersExpanded, useIsMobile, useWalletCollections } from 'nft/hooks'
|
||||||
import { WalletCollection } from 'nft/types'
|
import { WalletCollection } from 'nft/types'
|
||||||
import { CSSProperties, Dispatch, FormEvent, SetStateAction, useCallback, useEffect, useReducer, useState } from 'react'
|
import {
|
||||||
|
CSSProperties,
|
||||||
|
Dispatch,
|
||||||
|
FormEvent,
|
||||||
|
SetStateAction,
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useReducer,
|
||||||
|
useState,
|
||||||
|
} from 'react'
|
||||||
import { easings, useSpring } from 'react-spring'
|
import { easings, useSpring } from 'react-spring'
|
||||||
import AutoSizer from 'react-virtualized-auto-sizer'
|
import AutoSizer from 'react-virtualized-auto-sizer'
|
||||||
import { FixedSizeList, ListOnItemsRenderedProps } from 'react-window'
|
import { FixedSizeList, ListOnItemsRenderedProps } from 'react-window'
|
||||||
@ -18,6 +28,7 @@ import InfiniteLoader from 'react-window-infinite-loader'
|
|||||||
import styled from 'styled-components/macro'
|
import styled from 'styled-components/macro'
|
||||||
import { TRANSITION_DURATIONS } from 'theme/styles'
|
import { TRANSITION_DURATIONS } from 'theme/styles'
|
||||||
|
|
||||||
|
import { WALLET_COLLECTIONS_PAGINATION_LIMIT } from './ProfilePage'
|
||||||
import * as styles from './ProfilePage.css'
|
import * as styles from './ProfilePage.css'
|
||||||
|
|
||||||
const COLLECTION_ROW_HEIGHT = 44
|
const COLLECTION_ROW_HEIGHT = 44
|
||||||
@ -81,6 +92,12 @@ export const FilterSidebar = ({
|
|||||||
easing: easings.easeOutSine,
|
easing: easings.easeOutSine,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const hideSearch = useMemo(
|
||||||
|
() => (walletCollections && walletCollections?.length >= WALLET_COLLECTIONS_PAGINATION_LIMIT) || isFetchingNextPage,
|
||||||
|
[walletCollections, isFetchingNextPage]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
<AnimatedBox
|
<AnimatedBox
|
||||||
@ -120,6 +137,7 @@ export const FilterSidebar = ({
|
|||||||
fetchNextPage={fetchNextPage}
|
fetchNextPage={fetchNextPage}
|
||||||
hasNextPage={hasNextPage}
|
hasNextPage={hasNextPage}
|
||||||
isFetchingNextPage={isFetchingNextPage}
|
isFetchingNextPage={isFetchingNextPage}
|
||||||
|
hideSearch={hideSearch}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</AnimatedBox>
|
</AnimatedBox>
|
||||||
@ -133,6 +151,7 @@ const CollectionSelect = ({
|
|||||||
fetchNextPage,
|
fetchNextPage,
|
||||||
hasNextPage,
|
hasNextPage,
|
||||||
isFetchingNextPage,
|
isFetchingNextPage,
|
||||||
|
hideSearch,
|
||||||
}: {
|
}: {
|
||||||
collections: WalletCollection[]
|
collections: WalletCollection[]
|
||||||
collectionFilters: Array<string>
|
collectionFilters: Array<string>
|
||||||
@ -140,6 +159,7 @@ const CollectionSelect = ({
|
|||||||
fetchNextPage: () => void
|
fetchNextPage: () => void
|
||||||
hasNextPage?: boolean
|
hasNextPage?: boolean
|
||||||
isFetchingNextPage: boolean
|
isFetchingNextPage: boolean
|
||||||
|
hideSearch: boolean
|
||||||
}) => {
|
}) => {
|
||||||
const [collectionSearchText, setCollectionSearchText] = useState('')
|
const [collectionSearchText, setCollectionSearchText] = useState('')
|
||||||
const [displayCollections, setDisplayCollections] = useState(collections)
|
const [displayCollections, setDisplayCollections] = useState(collections)
|
||||||
@ -200,10 +220,12 @@ const CollectionSelect = ({
|
|||||||
</Box>
|
</Box>
|
||||||
<Box paddingBottom="12" borderRadius="8">
|
<Box paddingBottom="12" borderRadius="8">
|
||||||
<Column as="ul" paddingLeft="0" gap="10" style={{ maxHeight: '80vh' }}>
|
<Column as="ul" paddingLeft="0" gap="10" style={{ maxHeight: '80vh' }}>
|
||||||
|
{!hideSearch && (
|
||||||
<CollectionFilterSearch
|
<CollectionFilterSearch
|
||||||
collectionSearchText={collectionSearchText}
|
collectionSearchText={collectionSearchText}
|
||||||
setCollectionSearchText={setCollectionSearchText}
|
setCollectionSearchText={setCollectionSearchText}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
<ItemsContainer>
|
<ItemsContainer>
|
||||||
<AutoSizer disableWidth>
|
<AutoSizer disableWidth>
|
||||||
{({ height }) => (
|
{({ height }) => (
|
||||||
|
@ -51,7 +51,7 @@ const ProfileHeader = styled.div`
|
|||||||
`
|
`
|
||||||
|
|
||||||
export const DEFAULT_WALLET_ASSET_QUERY_AMOUNT = 25
|
export const DEFAULT_WALLET_ASSET_QUERY_AMOUNT = 25
|
||||||
const WALLET_COLLECTIONS_PAGINATION_LIMIT = 300
|
export const WALLET_COLLECTIONS_PAGINATION_LIMIT = 300
|
||||||
const FILTER_SIDEBAR_WIDTH = 300
|
const FILTER_SIDEBAR_WIDTH = 300
|
||||||
const PADDING = 16
|
const PADDING = 16
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user