Skip to content

Commit

Permalink
some adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigoncalves committed Feb 21, 2024
1 parent 329363c commit 18c83bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
16 changes: 8 additions & 8 deletions src/components/token/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChainID } from 'lib/eoaWallet'

import { TokenSymbol, getTokenByChainId } from 'screens/home/TokenImage'
import { TokenSymbol, getTokenSymbolByChainId } from 'screens/home/TokenImage'
import { TokenOrBitcoinNetwork } from 'shared/types'

/**
Expand All @@ -14,17 +14,17 @@ export const sortBalancesBySymbol = (
balances: Array<TokenOrBitcoinNetwork>,
chainId: ChainID,
): Array<TokenOrBitcoinNetwork> => {
const rif = getTokenByChainId(TokenSymbol.RIF, chainId)
const usdrif = getTokenByChainId(TokenSymbol.USDRIF, chainId)
const rbtc = getTokenByChainId(TokenSymbol.RBTC, chainId)
const btc = getTokenByChainId(TokenSymbol.BTC, chainId)
const rdoc = getTokenByChainId(TokenSymbol.RDOC, chainId)
const rif = getTokenSymbolByChainId(TokenSymbol.RIF, chainId)
const usdrif = getTokenSymbolByChainId(TokenSymbol.USDRIF, chainId)
const rbtc = getTokenSymbolByChainId(TokenSymbol.RBTC, chainId)
const btc = getTokenSymbolByChainId(TokenSymbol.BTC, chainId)
const rdoc = getTokenSymbolByChainId(TokenSymbol.RDOC, chainId)

const defaultOrder = [rif, usdrif, rbtc, btc, rdoc]

return balances.sort((a, b) => {
const symbolA = getTokenByChainId(a.symbol, chainId)
const symbolB = getTokenByChainId(b.symbol, chainId)
const symbolA = getTokenSymbolByChainId(a.symbol, chainId)
const symbolB = getTokenSymbolByChainId(b.symbol, chainId)
const indexA = defaultOrder.indexOf(symbolA)
const indexB = defaultOrder.indexOf(symbolB)

Expand Down
10 changes: 3 additions & 7 deletions src/screens/home/PortfolioComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ import { useTranslation } from 'react-i18next'
import { ScrollView, StyleProp, View, ViewStyle } from 'react-native'

import { PortfolioCard } from 'components/Porfolio/PortfolioCard'
import {
sortBalancesBySymbol,
sortTokensBySymbol,
} from 'components/token/utils'
import { sortBalancesBySymbol } from 'components/token/utils'
import { getTokenColor } from 'screens/home/tokenColor'
import { sharedColors } from 'shared/constants'
import { TokenOrBitcoinNetwork } from 'shared/types'
import { useAppSelector } from 'src/redux/storeUtils'
import { selectChainId } from 'src/redux/slices/settingsSlice'
import { getCurrentChainId } from 'storage/ChainStorage'

interface Props {
setSelectedAddress: (token: string | undefined) => void
Expand All @@ -29,7 +25,7 @@ export const PortfolioComponent = ({
showTotalCard = true,
style,
}: Props) => {
const chainId = useAppSelector(selectChainId)
const chainId = getCurrentChainId()
const { t } = useTranslation()
const [isTotalCardSelected, setIsTotalCardSelected] = useState<boolean>(
showTotalCard && !selectedAddress,
Expand Down
2 changes: 1 addition & 1 deletion src/screens/home/TokenImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export const getIconSource = (
}
}

export const getTokenByChainId = (
export const getTokenSymbolByChainId = (
symbol: string | TokenSymbol,
chainId: ChainID,
) => {
Expand Down

0 comments on commit 18c83bb

Please sign in to comment.