feat(course-page): add dynamic CTA and loading state to leaderboard rank#3535
feat(course-page): add dynamic CTA and loading state to leaderboard rank#3535rohitpaulk wants to merge 1 commit intomainfrom
Conversation
Display a loading animation while fetching leaderboard rank and show a dynamic call-to-action (CTA) message based on the user's progress and course stage. Update modal size for better layout consistency and adjust styles for improved spacing and alignment. These changes enhance user engagement by providing contextual feedback and encouragement upon completing course steps.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
|
||
| await timeout(500); | ||
| this.ctaText = this.computedCtaText; | ||
| } |
There was a problem hiding this comment.
Race condition between CTA check and assignment
The computedCtaText getter is called twice in refreshRankTask - once to check if it's truthy, then again 3000ms later for assignment. If the underlying leaderboard data changes during this window, the getter could return null on the second call even though the condition passed. This would assign null to ctaText (which is typed as string), causing the CTA to unexpectedly disappear. The value returned from the first check could be captured and reused instead.
|
|
||
| await timeout(500); | ||
| this.ctaText = this.computedCtaText; | ||
| } |
There was a problem hiding this comment.
Loading indicator stuck forever if data fetch fails
The original code used refreshRankTask.isRunning for the loading state, which automatically becomes false when the task ends regardless of success or failure. The new code uses a manual isLoadingRank tracked property that's only set to false after loadOrRefresh() succeeds. If the fetch throws an error, isLoadingRank remains true and the loading animation displays indefinitely with no way to recover.
Bundle ReportChanges will decrease total bundle size by 143 bytes (-0.0%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: client-array-pushAssets Changed:
|
Display a loading animation while fetching leaderboard rank and show a
dynamic call-to-action (CTA) message based on the user's progress and
course stage. Update modal size for better layout consistency and adjust
styles for improved spacing and alignment.
These changes enhance user engagement by providing contextual feedback
and encouragement upon completing course steps.
Note
Enhances the completion modal and leaderboard rank section with loading and contextual feedback.
isLoadingRankand animated CTA text (ctaText) driven bycomputeLeaderboardCTA, shown when@shouldShowCTAis trueLanguageLeaderboardRankSection:currentCourseStage,repository, andshouldShowCTA; rank refresh now usesrefreshRankTaskwith staged timeouts and switches template to useisLoadingRankmax-w-xs, rank section madew-full, and spacing adjustments (e.g.,mb-2)Written by Cursor Bugbot for commit efff243. This will update automatically on new commits. Configure here.