Conversation
📝 WalkthroughWalkthroughThe PR refactors the leaderboard query control mechanism from a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
components/brain/my-stream/votes/MyStreamWaveMyVotesReset.tsx (1)
67-85:⚠️ Potential issue | 🟠 MajorMove the reset teardown into
finally.If any
mutateAsynccall rejects, Lines 82-85 are skipped. That leaves localisResettingstucktrueand the parent stuck inonResettingChange(true), so the buttons stay disabled and leaderboard fetching never resumes.💡 Suggested fix
const selectedDropIds = Array.from(selected); - for (const dropId of selectedDropIds) { - await rateChangeMutation.mutateAsync({ dropId }); - setResetProgress((prev) => prev + 1); - } - - setIsResetting(false); - setResetProgress(0); - onResettingChange(false); - setTotalCount(0); + try { + for (const dropId of selectedDropIds) { + await rateChangeMutation.mutateAsync({ dropId }); + setResetProgress((prev) => prev + 1); + } + } finally { + setIsResetting(false); + setResetProgress(0); + onResettingChange(false); + setTotalCount(0); + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@components/brain/my-stream/votes/MyStreamWaveMyVotesReset.tsx` around lines 67 - 85, handleReset currently does the teardown (setIsResetting(false), setResetProgress(0), onResettingChange(false), setTotalCount(0)) only after the loop, so any rejection from rateChangeMutation.mutateAsync will skip those lines; wrap the mutation loop in a try block and move all teardown calls into a finally block to ensure they always run; keep the loop using rateChangeMutation.mutateAsync({ dropId }) and the progress update setResetProgress((prev)=>prev+1) inside try, and in finally call setIsResetting(false), setResetProgress(0), onResettingChange(false) and setTotalCount(0) so state/parent callbacks are always restored even on error.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@components/brain/my-stream/votes/MyStreamWaveMyVotes.tsx`:
- Around line 25-31: The intersection observer that triggers manual pagination
still calls fetchNextPage() while votes are resetting because TanStack Query's
enabled:false only stops automatic fetching; update the observer's guard to also
check isResettingVotes (use the isResettingVotes state) before calling
fetchNextPage() so that when isResettingVotes is true the observer will not call
fetchNextPage(); ensure you reference the fetchNextPage function and
isResettingVotes state in the observer condition (the same observer that
currently calls fetchNextPage()).
---
Outside diff comments:
In `@components/brain/my-stream/votes/MyStreamWaveMyVotesReset.tsx`:
- Around line 67-85: handleReset currently does the teardown
(setIsResetting(false), setResetProgress(0), onResettingChange(false),
setTotalCount(0)) only after the loop, so any rejection from
rateChangeMutation.mutateAsync will skip those lines; wrap the mutation loop in
a try block and move all teardown calls into a finally block to ensure they
always run; keep the loop using rateChangeMutation.mutateAsync({ dropId }) and
the progress update setResetProgress((prev)=>prev+1) inside try, and in finally
call setIsResetting(false), setResetProgress(0), onResettingChange(false) and
setTotalCount(0) so state/parent callbacks are always restored even on error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 47c64915-498d-41fe-8316-ad67196af8e7
📒 Files selected for processing (7)
__tests__/components/brain/my-stream/votes/MyStreamWaveMyVotesReset.test.tsx__tests__/hooks/useWaveDropsLeaderboard.extra.test.ts__tests__/hooks/useWaveDropsLeaderboard.test.tscomponents/brain/my-stream/votes/MyStreamWaveMyVotes.tsxcomponents/brain/my-stream/votes/MyStreamWaveMyVotesReset.tsxcomponents/home/next-mint-leading/NextMintLeadingSection.tsxhooks/useWaveDropsLeaderboard.ts



Summary by CodeRabbit
Bug Fixes
Refactor