Repository navigation
fix(claim): show loading spinner while claim data loads on network switch (#614) - #646
Closed
ocakciomursel-pixel wants to merge 3 commits into
Closed
ocakciomursel-pixel wants to merge 3 commits into
ocakciomursel-pixel wants to merge 3 commits into
Conversation
…itch (GoodDollar#614) - Detect in-flight UBI/Identity multicall and entitlement resolution after switching networks (e.g., to XDC) - Render a page-loader Spinner instead of an unresponsive blue "CLAIM NOW" button while claim data is loading - Forward refresh={refreshRate} to ClaimButton so it polls everyBlock on network switch Fixes GoodDollar#614
Contributor
There was a problem hiding this comment.
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/pages/gd/Claim/OldClaim.tsx" line_range="158-162" />
<code_context>
)
+ const isClaimDataLoading = Boolean(
+ address &&
+ (activeChainFeatures['claimEnabled'] || !isProd || isMinipay) &&
+ (!nextClaimTime ||
+ nextClaimTime.getTime() <= INITIAL_PERIOD_EPOCH_MS ||
+ (isWhitelisted && (claimAmount === undefined || claimed === undefined)))
+ )
+
</code_context>
<issue_to_address>
**Previous chain data remains visible**
When the wallet switches chains while `useClaim` still exposes the previous chain’s resolved data, `isClaimDataLoading` and the outer `claimed` branch consume that data before the new entitlement resolves, so the old claim button remains actionable or the old claimed view appears. The user sees the wrong chain’s claim state.
Bind claim data to the active chain and keep both the claim button and claimed view behind loading until the new chain’s data is ready.
Also at `src/pages/gd/Claim/OldClaim.tsx:437-440`.
</issue_to_address>
### Comment 2
<location path="src/pages/gd/Claim/OldClaim.tsx" line_range="160-162" />
<code_context>
+ const isClaimDataLoading = Boolean(
+ address &&
+ (activeChainFeatures['claimEnabled'] || !isProd || isMinipay) &&
+ (!nextClaimTime ||
+ nextClaimTime.getTime() <= INITIAL_PERIOD_EPOCH_MS ||
+ (isWhitelisted && (claimAmount === undefined || claimed === undefined)))
+ )
+
</code_context>
<issue_to_address>
**Claim page stays loading**
When the claim-data request fails or never supplies `nextClaimTime`, `isClaimDataLoading` remains true, so the spinner replaces `ClaimButton` indefinitely and the user has no in-page error or retry.
Handle a missing `nextClaimTime` after a failed or stalled request with an error state and a retry path instead of keeping the page loading.
Also at `src/pages/gd/Claim/OldClaim.tsx:437-441`.
</issue_to_address>
### Comment 3
<location path="src/pages/gd/Claim/OldClaim.tsx" line_range="452" />
<code_context>
- handleConnect={handleConnect}
- chainId={+(chainId ?? 42220)}
- onEvent={handleEvents}
- />
+ {isClaimDataLoading ? (
+ <Center w="full" py="12">
</code_context>
<issue_to_address>
**Claim reads poll twice per block**
When a connected user has an unclaimed amount and the page is open, `refreshRate` is set to `everyBlock` whenever an unclaimed `claimAmount` is available, so forwarding it makes `ClaimButton`'s internal `useClaim` poll alongside the page's existing `useClaim`. The duplicate polling increases RPC traffic and can hit provider limits.
Avoid polling the same claim data from both components, or share the page's claim data with `ClaimButton` instead of forwarding an every-block refresh rate.
</issue_to_address>Sourcery assessment
Approval pending. 3 findings to address first.
Blocking findings: src/pages/gd/Claim/OldClaim.tsx:162, src/pages/gd/Claim/OldClaim.tsx:162, src/pages/gd/Claim/OldClaim.tsx:452
added 2 commits
October 17, 2026 22:15
…n stall (GoodDollar#614) - Track dataChainId to prevent previous chain entitlement from rendering on chain switch - Keep both ClaimBalance and ClaimButton behind loading state until active chain resolves - Add timeout and Retry button for stalled or failed claim data requests - Remove refresh prop on ClaimButton to avoid duplicate every-block polling
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #614.
Problem
When switching to XDC (
chainId === 50, which rendersOldClaim) or switching networks while connected:useClaimfirst resolveswhitelistedRoot+periodStart/currentDay, and only afterwhitelistedRootresolves doesuseEntitlementForRootfetchclaimAmount(checkEntitlement).claimAmountandclaimedareundefined, causingClaimButtonto render a blue button saying"CLAIM NOW"(without the claim amount) and withdisabled={undefined}, where pressing it does nothing.OldClaimdid not passrefresh={refreshRate}toClaimButton, leavingClaimButton's internaluseClaimhook at its default"never"refresh setting instead of"everyBlock"on chain switch.Solution
isClaimDataLoadingwhen a wallet is connected on a claim-enabled chain and either the initial UBI/Identity multicall has not resolved yet or the user is whitelisted whileclaimAmount/claimedare still resolving.<Spinner variant="page-loader" size="lg" />whileisClaimDataLoadingis true and guardhandleClaimagainst premature invocation.refresh={refreshRate}to<ClaimButton />so its internaluseClaimhook stays synchronized withOldClaim's polling rate.Fixes #614
Summary by Sourcery
Prevent incomplete claim data from rendering an actionable claim button during network transitions.
Bug Fixes:
Enhancements: