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

fix: remove no tokens state and replace w loading (#4847)

* remove no tokens state and replace w loading

* update snapshot
parent 978e3f94
...@@ -212,12 +212,74 @@ exports[`renders currency rows correctly when currencies list is non-empty 1`] = ...@@ -212,12 +212,74 @@ exports[`renders currency rows correctly when currencies list is non-empty 1`] =
exports[`renders loading rows when isLoading is true 1`] = ` exports[`renders loading rows when isLoading is true 1`] = `
<DocumentFragment> <DocumentFragment>
<div .c0 {
display: grid;
}
.c0 > div {
-webkit-animation: fAQEyV 1.5s infinite;
animation: fAQEyV 1.5s infinite;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
background: linear-gradient( to left,#F7F8FA 25%,#EDEEF2 50%,#F7F8FA 75% );
background-size: 400%;
border-radius: 12px;
height: 2.4em;
will-change: background-position;
}
.c1 {
grid-column-gap: 0.5em;
grid-template-columns: repeat(12,1fr);
max-width: 960px;
padding: 12px 20px;
}
.c1 > div:nth-child(4n + 1) {
grid-column: 1 / 8;
height: 1em;
margin-bottom: 0.25em;
}
.c1 > div:nth-child(4n + 2) {
grid-column: 12;
height: 1em;
margin-top: 0.25em;
}
.c1 > div:nth-child(4n + 3) {
grid-column: 1 / 4;
height: 0.75em;
}
<div
style="position: relative; height: 10px; width: 100%; overflow: auto; will-change: transform; direction: ltr;" style="position: relative; height: 10px; width: 100%; overflow: auto; will-change: transform; direction: ltr;"
> >
<div <div
style="height: 0px; width: 100%;" style="height: 560px; width: 100%;"
/> >
<div
class="c0 c1"
>
<div />
<div />
<div />
</div>
<div
class="c0 c1"
>
<div />
<div />
<div />
</div>
<div
class="c0 c1"
>
<div />
<div />
<div />
</div>
</div>
</div> </div>
</DocumentFragment> </DocumentFragment>
`; `;
...@@ -227,6 +227,14 @@ export const formatAnalyticsEventProperties = ( ...@@ -227,6 +227,14 @@ export const formatAnalyticsEventProperties = (
: { search_token_address_input: isAddressSearch }), : { search_token_address_input: isAddressSearch }),
}) })
const LoadingRow = () => (
<LoadingRows>
<div />
<div />
<div />
</LoadingRows>
)
export default function CurrencyList({ export default function CurrencyList({
height, height,
currencies, currencies,
...@@ -272,13 +280,7 @@ export default function CurrencyList({ ...@@ -272,13 +280,7 @@ export default function CurrencyList({
const token = currency?.wrapped const token = currency?.wrapped
if (isLoading) { if (isLoading) {
return ( return LoadingRow()
<LoadingRows>
<div />
<div />
<div />
</LoadingRows>
)
} else if (currency) { } else if (currency) {
return ( return (
<CurrencyRow <CurrencyRow
...@@ -303,7 +305,11 @@ export default function CurrencyList({ ...@@ -303,7 +305,11 @@ export default function CurrencyList({
return currencyKey(currency) return currencyKey(currency)
}, []) }, [])
return ( return isLoading ? (
<FixedSizeList height={height} ref={fixedListRef as any} width="100%" itemData={[]} itemCount={10} itemSize={56}>
{LoadingRow}
</FixedSizeList>
) : (
<FixedSizeList <FixedSizeList
height={height} height={height}
ref={fixedListRef as any} ref={fixedListRef as any}
......
...@@ -107,11 +107,12 @@ export function CurrencySearch({ ...@@ -107,11 +107,12 @@ export function CurrencySearch({
return Object.values(allTokens).filter(getTokenFilter(debouncedQuery)) return Object.values(allTokens).filter(getTokenFilter(debouncedQuery))
}, [allTokens, debouncedQuery]) }, [allTokens, debouncedQuery])
const [balances, balancesIsLoading] = useAllTokenBalances() const [balances, balancesAreLoading] = useAllTokenBalances()
const sortedTokens: Token[] = useMemo( const sortedTokens: Token[] = useMemo(
() => (!balancesIsLoading ? [...filteredTokens].sort(tokenComparator.bind(null, balances)) : []), () => (!balancesAreLoading ? [...filteredTokens].sort(tokenComparator.bind(null, balances)) : []),
[balances, filteredTokens, balancesIsLoading] [balances, filteredTokens, balancesAreLoading]
) )
const isLoading = Boolean(balancesAreLoading && !tokenLoaderTimerElapsed)
const filteredSortedTokens = useSortTokensByQuery(debouncedQuery, sortedTokens) const filteredSortedTokens = useSortTokensByQuery(debouncedQuery, sortedTokens)
...@@ -241,7 +242,7 @@ export function CurrencySearch({ ...@@ -241,7 +242,7 @@ export function CurrencySearch({
)} )}
/> />
</Column> </Column>
) : filteredSortedTokens?.length > 0 || filteredInactiveTokens?.length > 0 ? ( ) : filteredSortedTokens?.length > 0 || filteredInactiveTokens?.length > 0 || isLoading ? (
<div style={{ flex: '1' }}> <div style={{ flex: '1' }}>
<AutoSizer disableWidth> <AutoSizer disableWidth>
{({ height }) => ( {({ height }) => (
...@@ -254,7 +255,7 @@ export function CurrencySearch({ ...@@ -254,7 +255,7 @@ export function CurrencySearch({
selectedCurrency={selectedCurrency} selectedCurrency={selectedCurrency}
fixedListRef={fixedList} fixedListRef={fixedList}
showCurrencyAmount={showCurrencyAmount} showCurrencyAmount={showCurrencyAmount}
isLoading={balancesIsLoading && !tokenLoaderTimerElapsed} isLoading={isLoading}
searchQuery={searchQuery} searchQuery={searchQuery}
isAddressSearch={isAddressSearch} isAddressSearch={isAddressSearch}
/> />
......
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