Skip to content

reorder leaderboard sort options#1745

Merged
simo6529 merged 1 commit intomainfrom
reorder-leaderboard-sort
Jan 15, 2026
Merged

reorder leaderboard sort options#1745
simo6529 merged 1 commit intomainfrom
reorder-leaderboard-sort

Conversation

@simo6529
Copy link
Copy Markdown
Collaborator

@simo6529 simo6529 commented Jan 15, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced error handling in leaderboard sorting to prevent potential runtime issues.
  • Style

    • Updated button labels in sorting controls for improved clarity.

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: Simo <simo@6529.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

This PR expands the public API of the WaveleaderboardSort component by adding onSortChange callback and optional waveId props, enabling external control of sorting behavior. The component's UI reorders a TREND button with updated labeling. Import statements are reorganized in both the component and test files. Error handling is tightened with proper type checking.

Changes

Cohort / File(s) Summary
WaveleaderboardSort Component & Test
components/waves/leaderboard/header/WaveleaderboardSort.tsx, __tests__/components/waves/leaderboard/header/WaveleaderboardSort.test.tsx
Component props interface expanded with onSortChange callback and optional waveId parameter for external sort control and wave context. UI button reordered with "Hot" label. Error handling improved with unknown type checking. Test updated to reference new label and import order adjusted.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • Trending to leaderboard #1739: Modifies the same WaveleaderboardSort component and tests, reworking TREND button placement/labeling and prefetch-on-hover behavior.

Suggested reviewers

  • ragnep

Poem

🐰 The leaderboard hops with new control,
Props expanded to reach the goal,
Buttons reordered, labels shine bright,
"Hot" trends dance in the code's soft light! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'reorder leaderboard sort options' accurately summarizes the main change: reordering UI buttons in the leaderboard sort component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

🧹 Recent nitpick comments
components/waves/leaderboard/header/WaveleaderboardSort.tsx (1)

15-19: Minor: Redundant | undefined in optional prop.

The ? already makes the property optional (which includes undefined). The explicit | undefined is redundant.

Suggested simplification
 interface WaveleaderboardSortProps {
   readonly sort: WaveDropsLeaderboardSort;
   readonly onSortChange: (sort: WaveDropsLeaderboardSort) => void;
-  readonly waveId?: string | undefined;
+  readonly waveId?: string;
 }

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5dc9a89 and 5407baf.

📒 Files selected for processing (2)
  • __tests__/components/waves/leaderboard/header/WaveleaderboardSort.test.tsx
  • components/waves/leaderboard/header/WaveleaderboardSort.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
__tests__/components/waves/leaderboard/header/WaveleaderboardSort.test.tsx (2)

3-5: Import reordering looks fine.

No functional changes, just reorganization of imports.


30-31: Test updated correctly to match the new button label.

The label change from "🔥 Hot" to "Hot" aligns with the component implementation. The test properly verifies onSortChange is called with WaveDropsLeaderboardSort.TREND.

components/waves/leaderboard/header/WaveleaderboardSort.tsx (3)

3-13: Good use of explicit type import.

Using import type for ApiDropsLeaderboardPage is a good practice - it ensures the import is erased at compile time and makes the code's intent clearer.


92-98: Good error handling improvement.

Typing the error as unknown and checking instanceof Error before accessing .message is the correct TypeScript pattern. This prevents runtime errors if the caught value isn't an Error object.


149-155: Button reordering looks good.

The TREND button is now positioned third in the sort options with a simplified "Hot" label (emoji removed). The implementation maintains consistent patterns with other buttons including the prefetch-on-hover behavior.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

@simo6529 simo6529 merged commit 33adc3f into main Jan 15, 2026
7 checks passed
@simo6529 simo6529 deleted the reorder-leaderboard-sort branch January 15, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants