Skip to content

Commit 4b26dc4

Browse files
kaladinlightclaude
andauthored
perf: stop polling fees in hidden tabs, refetch stale fees on return (#12787)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 429dde2 commit 4b26dc4

10 files changed

Lines changed: 14 additions & 124 deletions

File tree

‎src/components/Modals/Send/hooks/useSendDetails/useSendDetails.tsx‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ export const useSendDetails = (): UseSendDetailsReturnType => {
254254
// If the user get back and forth between the address and the amount form, we want to refetch the fees so it revalidate the form
255255
refetchOnMount: 'always',
256256
gcTime: 0,
257-
refetchIntervalInBackground: true,
258257
refetchInterval: 15_000,
258+
refetchOnWindowFocus: true,
259259
})
260260

261261
const {
@@ -270,7 +270,6 @@ export const useSendDetails = (): UseSendDetailsReturnType => {
270270
staleTime: 15 * 1000,
271271
enabled: false,
272272
retry: false,
273-
refetchIntervalInBackground: true,
274273
refetchInterval: 15_000,
275274
})
276275

‎src/components/MultiHopTrade/components/TradeConfirm/hooks/useTradeNetworkFeeCryptoBaseUnit.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ export const useTradeNetworkFeeCryptoBaseUnit = ({
7070

7171
const quoteNetworkFeesCryptoBaseUnitQuery = useQuery({
7272
queryKey: ['quoteNetworkFeesCryptoBaseUnit', tradeQuote],
73+
staleTime: 15_000,
7374
refetchInterval: 15_000,
75+
refetchOnWindowFocus: true,
7476
queryFn:
7577
enabled &&
7678
wallet &&

‎src/hooks/mutations/useApprove.ts‎

Lines changed: 0 additions & 103 deletions
This file was deleted.

‎src/hooks/queries/useApprovalFees.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ export const useApprovalFees = ({
6969
const tronFeesResult = useQuery({
7070
...reactQueries.common.tronFees({ chainId, to, from, value: '0', data: approveContractData }),
7171
enabled: Boolean(enabled && chainId === tronChainId && approveContractData && to && from),
72+
staleTime: 15_000,
7273
refetchInterval: isRefetchEnabled ? 15_000 : false,
74+
refetchOnWindowFocus: true,
7375
})
7476

7577
const evmFeesResult = useEvmFees({
@@ -79,7 +81,7 @@ export const useApprovalFees = ({
7981
chainId,
8082
data: approveContractData,
8183
enabled: Boolean(enabled && chainId && isEvmChainId(chainId)),
82-
refetchIntervalInBackground: isRefetchEnabled ? true : false,
84+
staleTime: 15_000,
8385
refetchInterval: isRefetchEnabled ? 15_000 : false,
8486
})
8587

‎src/hooks/queries/useEvmFees.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ type UseEvmFeesProps = {
2525
data: string | undefined
2626
enabled?: boolean
2727
refetchInterval: number | false | undefined
28-
refetchIntervalInBackground?: boolean
2928
staleTime?: number
3029
to: string | undefined
3130
value: string
@@ -42,7 +41,6 @@ export const useEvmFees = ({
4241
chainId,
4342
data,
4443
refetchInterval,
45-
refetchIntervalInBackground,
4644
to,
4745
value,
4846
enabled = true,
@@ -75,7 +73,7 @@ export const useEvmFees = ({
7573
: undefined,
7674
staleTime,
7775
refetchInterval,
78-
refetchIntervalInBackground,
76+
refetchOnWindowFocus: true,
7977
})
8078

8179
return query

‎src/hooks/queries/useGetEstimatedFeesQuery.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const useGetEstimatedFeesQuery = ({
6464

6565
const getEstimatedFeesQuery = useQuery({
6666
queryKey: estimatedFeesQueryKey,
67-
staleTime: 30_000,
67+
staleTime: 15_000,
6868
queryFn,
6969
enabled:
7070
enabled &&
@@ -74,9 +74,8 @@ export const useGetEstimatedFeesQuery = ({
7474
estimateFeesInput.accountId &&
7575
estimateFeesInput.amountCryptoPrecision,
7676
),
77-
// Ensures fees are refetched at an interval, including when the app is in the background
78-
refetchIntervalInBackground: true,
7977
refetchInterval: estimateFeesInput.disableRefetch ? false : 15_000,
78+
refetchOnWindowFocus: true,
8079
})
8180

8281
return getEstimatedFeesQuery

‎src/hooks/useArbitrumClaims/useArbitrumClaimTx.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export const useArbitrumClaimTx = (
6868
from: claimAccountId ? fromAccountId(claimAccountId).account : undefined,
6969
chainId: claim?.destinationChainId,
7070
data: executeTransactionDataResult.data,
71+
staleTime: 15_000,
7172
refetchInterval: 15_000,
7273
to: getAddress(arbitrumNetwork.ethBridge.outbox),
7374
value: '0',

‎src/pages/RFOX/components/Claim/ClaimConfirm.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,7 @@ export const ClaimConfirm: FC<
258258
} = useEvmFees({
259259
...claimFeesQueryInput,
260260
enabled: isGetClaimFeesEnabled,
261-
staleTime: 30_000,
262-
// Ensures fees are refetched at an interval, including when the app is in the background
263-
refetchIntervalInBackground: true,
261+
staleTime: 15_000,
264262
// Yeah this is arbitrary but come on, Arb is cheap
265263
refetchInterval: isGetClaimFeesEnabled ? 15_000 : false,
266264
})

‎src/pages/RFOX/components/Stake/hooks/useRfoxStake.tsx‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ export const useRfoxStake = ({
211211
const approvalFeesQuery = useEvmFees({
212212
...approvalFeesQueryInput,
213213
enabled: isGetApprovalFeesEnabled,
214-
staleTime: 30_000,
215-
// Ensures fees are refetched at an interval, including when the app is in the background
216-
refetchIntervalInBackground: true,
214+
staleTime: 15_000,
217215
// Yeah this is arbitrary but come on, Arb is cheap
218216
refetchInterval: 15_000,
219217
})
@@ -339,9 +337,7 @@ export const useRfoxStake = ({
339337
const stakeFeesQuery = useEvmFees({
340338
...stakeFeesQueryInput,
341339
enabled: isGetStakeFeesEnabled,
342-
staleTime: 30_000,
343-
// Ensures fees are refetched at an interval, including when the app is in the background
344-
refetchIntervalInBackground: true,
340+
staleTime: 15_000,
345341
// Yeah this is arbitrary but come on, Arb is cheap
346342
refetchInterval: 15_000,
347343
})

‎src/pages/RFOX/components/Unstake/hooks/useRfoxUnstake.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ export const useRfoxUnstake = ({
255255
const unstakeFeesQuery = useEvmFees({
256256
...unstakeFeesQueryInput,
257257
enabled: isGetUnstakeFeesEnabled,
258-
staleTime: 30_000,
259-
// Ensures fees are refetched at an interval, including when the app is in the background
260-
refetchIntervalInBackground: true,
258+
staleTime: 15_000,
261259
// Yeah this is arbitrary but come on, Arb is cheap
262260
refetchInterval: 15_000,
263261
})

0 commit comments

Comments
 (0)