Skip to content

Commit

Permalink
Merge pull request #1149 from interlay/tom/handle-rpc-staking-error
Browse files Browse the repository at this point in the history
[staking] Handle RPC error
  • Loading branch information
tomjeatt committed Apr 25, 2023
2 parents 8a65ce1 + 3cb97e1 commit 614883e
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/pages/Staking/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const Staking = (): JSX.Element => {
handleSubmit,
watch,
reset,
formState: { errors },
formState: { errors, isDirty, isValid },
trigger,
setValue
} = useForm<StakingFormData>({
Expand Down Expand Up @@ -200,7 +200,8 @@ const Staking = (): JSX.Element => {
isIdle: estimatedRewardAmountAndAPYIdle,
isLoading: estimatedRewardAmountAndAPYLoading,
data: estimatedRewardAmountAndAPY,
error: estimatedRewardAmountAndAPYError
error: estimatedRewardAmountAndAPYError,
refetch: estimatedRewardAmountAndAPYRefetch
} = useQuery<EstimatedRewardAmountAndAPY, Error>(
[
GENERIC_FETCHER,
Expand All @@ -212,11 +213,19 @@ const Staking = (): JSX.Element => {
],
genericFetcher<EstimatedRewardAmountAndAPY>(),
{
enabled: !!bridgeLoaded
enabled: false,
retry: false
}
);
useErrorHandler(estimatedRewardAmountAndAPYError);

// MEMO: This is being set outside of a useEffect because of
// an race condition. This is a underlying issue with the
// component and can't be easily fixed.
if (isValid || !isDirty) {
estimatedRewardAmountAndAPYRefetch();
}

const {
isIdle: stakedAmountAndEndBlockIdle,
isLoading: stakedAmountAndEndBlockLoading,
Expand Down Expand Up @@ -851,7 +860,7 @@ const Staking = (): JSX.Element => {
fullWidth
size='large'
type='submit'
disabled={initializing || unlockFirst}
disabled={initializing || unlockFirst || !isValid}
loading={initialStakeMutation.isLoading || moreStakeMutation.isLoading}
>
{submitButtonLabel}{' '}
Expand Down

2 comments on commit 614883e

@vercel
Copy link

@vercel vercel bot commented on 614883e Apr 25, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 614883e Apr 25, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.