fix(useSWR): request hooks revalidation on focus disabled (#340)

This commit is contained in:
Yusuf Seyrek 2023-08-05 12:52:11 +03:00 committed by GitHub
parent cec9e50955
commit c25d8607e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 15 additions and 1 deletions

View File

@ -5,5 +5,6 @@ import getAccount from 'api/accounts/getAccount'
export default function useAccounts(accountId?: string) {
return useSWR(`account${accountId}`, () => getAccount(accountId || ''), {
refreshInterval: 30000,
revalidateOnFocus: false,
})
}

View File

@ -6,5 +6,6 @@ export default function useAccounts(address?: string) {
return useSWR(`accounts${address}`, () => getAccounts(address || ''), {
suspense: true,
isPaused: () => !address,
revalidateOnFocus: false,
})
}

View File

@ -3,5 +3,7 @@ import useSWR from 'swr'
import calculateAssetIncentivesApy from 'api/incentives/calculateAssetIncentivesApy'
export default function useAssetIncentivesApy(denom: string) {
return useSWR(`assetIncentiveApy-${denom}`, () => calculateAssetIncentivesApy(denom))
return useSWR(`assetIncentiveApy-${denom}`, () => calculateAssetIncentivesApy(denom), {
revalidateOnFocus: false,
})
}

View File

@ -5,5 +5,6 @@ import getAssetParams from 'api/params/getAssetParams'
export default function useAssetParams() {
return useSWR('assetParams', getAssetParams, {
fallbackData: [],
revalidateOnFocus: false,
})
}

View File

@ -5,5 +5,6 @@ import getDepositedVaults from 'api/vaults/getDepositedVaults'
export default function useDepositedVaults(accountId: string) {
return useSWR(`depositedVaultsByAccount-${accountId}`, () => getDepositedVaults(accountId), {
suspense: true,
revalidateOnFocus: false,
})
}

View File

@ -6,5 +6,6 @@ export default function useMarketAssets() {
return useSWR(`marketAssets`, getMarkets, {
suspense: true,
fallbackData: [],
revalidateOnFocus: false,
})
}

View File

@ -6,5 +6,6 @@ export default function useMarketBorrowings() {
return useSWR(`marketBorrowings`, getMarketBorrowings, {
fallbackData: [],
suspense: false,
revalidateOnFocus: false,
})
}

View File

@ -6,5 +6,6 @@ export default function useMarketDeposits() {
return useSWR(`marketDeposits`, getMarketDeposits, {
suspense: true,
fallbackData: [],
revalidateOnFocus: false,
})
}

View File

@ -6,5 +6,6 @@ export default function useMarketLiquidities() {
return useSWR(`marketLiquidities`, getMarketLiquidities, {
suspense: true,
fallbackData: [],
revalidateOnFocus: false,
})
}

View File

@ -6,5 +6,6 @@ export default function usePrices() {
return useSWR('prices', getPrices, {
fallbackData: [],
refreshInterval: 30000,
revalidateOnFocus: false,
})
}

View File

@ -5,5 +5,6 @@ import getSwapRoute from 'api/swap/getSwapRoute'
export default function useSwapRoute(denomIn: string, denomOut: string) {
return useSWR(`swapRoute-${denomIn}-${denomOut}`, () => getSwapRoute(denomIn, denomOut), {
fallbackData: [],
revalidateOnFocus: false,
})
}

View File

@ -5,5 +5,6 @@ import { getVaultConfigs } from 'api/vaults/getVaultConfigs'
export default function useVaultConfigs() {
return useSWR('vaultConfigs', getVaultConfigs, {
fallbackData: [],
revalidateOnFocus: false,
})
}

View File

@ -5,5 +5,6 @@ import getVaults from 'api/vaults/getVaults'
export default function useVaults(address?: string) {
return useSWR(`vaults${address}`, () => getVaults(), {
suspense: true,
revalidateOnFocus: false,
})
}