Skip to content

Commit

Permalink
CR: update
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss committed Jul 30, 2024
2 parents 4435a0c + 998c61e commit 8e065b1
Show file tree
Hide file tree
Showing 7 changed files with 769 additions and 5 deletions.
1 change: 1 addition & 0 deletions apps/wallet-mobile/.storybook/storybook.requires.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const getTxDetails = async (cbor: string): Promise<TxDetails> => {
}

const useTxDetails = (cbor: string) => {
return useQuery({queryFn: () => getTxDetails(cbor)})
return useQuery({queryFn: () => getTxDetails(cbor), queryKey: ['txDetails', cbor]})
}

const useFormattedTransaction = (cbor: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {storiesOf} from '@storybook/react-native'
import React from 'react'

import {PreprodFaucetBanner} from './PreprodFaucetBanner'

storiesOf('Exchange PreprodFaucetBanner', module) //
.add('initial', () => <PreprodFaucetBanner />)

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import {isPrimaryToken} from '@yoroi/portfolio'
import {useTheme} from '@yoroi/theme'
import {Chain} from '@yoroi/types'
import * as React from 'react'
import {FlatList, StyleSheet, Text, TouchableOpacity, useWindowDimensions, View} from 'react-native'

import {Icon, Spacer} from '../../../../../components'
import {makeList} from '../../../../../kernel/utils'
import {PreprodFaucetBanner} from '../../../../Exchange/common/ShowBuyBanner/PreprodFaucetBanner'
import {useSelectedWallet} from '../../../../WalletManager/common/hooks/useSelectedWallet'
import {useWalletManager} from '../../../../WalletManager/context/WalletManagerProvider'
import {usePortfolioBalances} from '../../../common/hooks/usePortfolioBalances'
import {useGetTokensWithBalance} from '../../../common/useGetTokensWithBalance'
import {useNavigateTo} from '../../../common/useNavigateTo'
Expand All @@ -23,6 +26,9 @@ export const DashboardTokensList = () => {
const {isLoading} = useGetTokensWithBalance()
const {wallet} = useSelectedWallet()
const balances = usePortfolioBalances({wallet})
const {
selected: {network},
} = useWalletManager()

const tokensList = React.useMemo(() => balances.fts ?? [], [balances.fts])
const isJustADA = React.useMemo(() => {
Expand Down Expand Up @@ -61,7 +67,7 @@ export const DashboardTokensList = () => {
if (isZeroADABalance) {
return (
<View style={styles.container}>
<BuyADABanner />
{network === Chain.Network.Preprod ? <PreprodFaucetBanner /> : <BuyADABanner />}
</View>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ export const TxList = (props: Props) => {
const {wallet} = useSelectedWallet()

const filter = useTxFilter()
const transactions = useTransactionInfos({wallet})
const filteredTransactions = React.useMemo(() => filterTransactions(transactions, filter), [transactions, filter])
const transactionInfos = useTransactionInfos({wallet})
const filteredTransactions = React.useMemo(
() => filterTransactions(transactionInfos, filter),
[transactionInfos, filter],
)

const [loadedTxs, setLoadedTxs] = React.useState(filteredTransactions.slice(0, batchSize))
const [currentIndex, setCurrentIndex] = React.useState(batchSize)

React.useEffect(() => {
setLoadedTxs(filteredTransactions.slice(0, currentIndex + batchSize))
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [transactionInfos]) // must be transactionInfos

const handleOnEndReached = React.useCallback(() => {
if (currentIndex >= filteredTransactions.length) return
const nextBatch = filteredTransactions.slice(currentIndex, currentIndex + batchSize)
Expand Down
2 changes: 1 addition & 1 deletion apps/wallet-mobile/src/yoroi-wallets/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export const useTransactionInfos = ({wallet}: {wallet: YoroiWallet}) => {
const unsubscribe = wallet.subscribe((event) => {
if (event.type !== 'transactions') return

setTransactionInfos(wallet.transactions)
setTransactionInfos(() => wallet.transactions)
})
return () => unsubscribe?.()
}, [wallet])
Expand Down

0 comments on commit 8e065b1

Please sign in to comment.