Skip to content

Commit

Permalink
Merge pull request #189 from reservoirprotocol/ted/relay-5398-decoupl…
Browse files Browse the repository at this point in the history
…e-dune-balance-fetch-from-tokens-list

Decouple dune balance loading from tokens list
  • Loading branch information
ted-palmer authored Jul 23, 2024
2 parents 579b626 + 00da309 commit 01d4b3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-maps-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@reservoir0x/relay-kit-ui': patch
---

Decouple dune balance loading from token selector
12 changes: 9 additions & 3 deletions packages/ui/src/components/common/TokenSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
ChainIcon,
Flex,
Input,
Skeleton,
Text
} from '../primitives/index.js'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
Expand Down Expand Up @@ -263,8 +264,7 @@ const TokenSelector: FC<TokenSelectorProps> = ({
tokenBalances
])

const isLoading =
isLoadingDuneBalances || isLoadingSuggestedTokens || isLoadingTokenList
const isLoading = isLoadingSuggestedTokens || isLoadingTokenList

// eslint-disable-next-line react-hooks/exhaustive-deps
const chainFuse = new Fuse(
Expand Down Expand Up @@ -530,6 +530,7 @@ const TokenSelector: FC<TokenSelectorProps> = ({
currencyList={list as EnhancedCurrencyList}
setCurrencyList={setCurrencyList}
selectToken={selectToken}
isLoadingDuneBalances={isLoadingDuneBalances}
key={idx}
/>
) : null
Expand Down Expand Up @@ -678,12 +679,14 @@ type CurrencyRowProps = {
currencyList: EnhancedCurrencyList
setCurrencyList: (currencyList: EnhancedCurrencyList) => void
selectToken: (currency: Currency, chainId?: number) => void
isLoadingDuneBalances: boolean
}

const CurrencyRow: FC<CurrencyRowProps> = ({
currencyList,
setCurrencyList,
selectToken
selectToken,
isLoadingDuneBalances
}) => {
const balance = currencyList.totalBalance
const decimals =
Expand Down Expand Up @@ -760,6 +763,9 @@ const CurrencyRow: FC<CurrencyRowProps> = ({
</Text>
) : null}
</Flex>
{isLoadingDuneBalances && !balance ? (
<Skeleton css={{ ml: 'auto', width: 60 }} />
) : null}
{balance ? (
<Text color="subtle" style="subtitle3" css={{ ml: 'auto' }}>
{formatBN(balance, 5, decimals, compactBalance)}
Expand Down

0 comments on commit 01d4b3e

Please sign in to comment.