Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip some queries #30

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/app/AppStatusHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default function AppStatusHeader() {
// XCH
const { data: walletBalance } = useGetWalletBalanceQuery(
{ walletId: chiaWalletId },
{ pollingInterval: 10000 }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any harm in making this change, but I also don't see any reason why it would make a difference. chiaWalletId defined at the top as const chiaWalletId: number = 1, so it should never be anything but 1

{ pollingInterval: 10000, skip: !chiaWalletId }
)

const { wallet, unit = '', loading } = useWallet(chiaWalletId)
Expand Down
1 change: 1 addition & 0 deletions src/components/token/TokenContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const TokenContent = () => {
},
{
pollingInterval: 10000,
skip: !walletId,
}
)

Expand Down
7 changes: 5 additions & 2 deletions src/components/token/TokenListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ const TokenListItem = ({ walletId }: TokenListItemProps) => {
)

const { walletId: selectedWalletId, setWalletId } = useSelectedWallet()
const { data: assetId } = useGetCATAssetIdQuery({ walletId: walletId })
const { data: assetId } = useGetCATAssetIdQuery(
{ walletId: walletId },
{ skip: !walletId }
)
const {
data: asset,
isLoading: isLoadingAsset,
Expand All @@ -85,7 +88,7 @@ const TokenListItem = ({ walletId }: TokenListItemProps) => {

const { data: walletBalance } = useGetWalletBalanceQuery(
{ walletId },
{ pollingInterval: 10000 }
{ pollingInterval: 10000, skip: !walletId }
)
const { wallet, unit = '' } = useWallet(walletId)
const isSelected = walletId === Number(selectedWalletId)
Expand Down
1 change: 1 addition & 0 deletions src/components/transaction/TransactionCATInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const TransactionCATInput = () => {
},
{
pollingInterval: 10000,
skip: !walletId,
}
)
const {
Expand Down
5 changes: 4 additions & 1 deletion src/hooks/wallet/useSelectedWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { useGetCATAssetIdQuery } from '@chia/api-react'
const useSelectedWallet = () => {
const walletId = useTypedSelector((state) => state.wallet.walletId)
const wallets = useWallet(walletId)
const { data: assetId } = useGetCATAssetIdQuery({ walletId: walletId })
const { data: assetId } = useGetCATAssetIdQuery(
{ walletId: walletId },
{ skip: !walletId }
)
const {
data: asset,
isLoading: isLoadingAsset,
Expand Down
6 changes: 5 additions & 1 deletion src/pages/Detokenization/CancelDetokenization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ const CancelDetokenization = () => {
mode: 'onChange',
})

const { data: assetId } = useGetCATAssetIdQuery({ walletId })
const { data: assetId } = useGetCATAssetIdQuery(
{ walletId: walletId },
{ skip: !walletId }
)

const { data: cwAsset, isLoading: isLoadingAsset } =
useGetAllCWAssetsById(assetId)
Expand All @@ -92,6 +95,7 @@ const CancelDetokenization = () => {
},
{
pollingInterval: 10000,
skip: !walletId,
}
)

Expand Down
6 changes: 5 additions & 1 deletion src/pages/Detokenization/RequestDetokenization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,18 @@ const RequestDetokenization = () => {
})
const { register, formState, handleSubmit, reset, getValues } = methods

const { data: assetId } = useGetCATAssetIdQuery({ walletId })
const { data: assetId } = useGetCATAssetIdQuery(
{ walletId: walletId },
{ skip: !walletId }
)
const { data: cwAsset } = useGetAllCWAssetsById(assetId)
const { data: walletBalance } = useGetWalletBalanceQuery(
{
walletId,
},
{
pollingInterval: 10000,
skip: !walletId,
}
)

Expand Down
6 changes: 5 additions & 1 deletion src/pages/Retire/Retire.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ const Retire = () => {
mode: 'onChange',
})

const { data: assetId } = useGetCATAssetIdQuery({ walletId })
const { data: assetId } = useGetCATAssetIdQuery(
{ walletId: walletId },
{ skip: !walletId }
)

const { data: cwAsset, isLoading: isLoadingAsset } =
useGetAllCWAssetsById(assetId)
Expand All @@ -75,6 +78,7 @@ const Retire = () => {
},
{
pollingInterval: 10000,
skip: !walletId,
}
)

Expand Down
6 changes: 5 additions & 1 deletion src/pages/Send/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ const Send = () => {
mode: 'onChange',
})

const { data: assetId } = useGetCATAssetIdQuery({ walletId })
const { data: assetId } = useGetCATAssetIdQuery(
{ walletId: walletId },
{ skip: !walletId }
)

const { data: cwAsset, isLoading: isLoadingAsset } =
useGetAllCWAssetsById(assetId)
Expand All @@ -66,6 +69,7 @@ const Send = () => {
},
{
pollingInterval: 10000,
skip: !walletId,
}
)

Expand Down