Skip to content

fix: eliminate duplicate courses API requests on courses page - #530

Open
Ranjeet2063 wants to merge 2 commits into
ChainLearnOfficial:mainfrom
Ranjeet2063:fix/courses-duplicate-api-517
Open

Ranjeet2063 wants to merge 2 commits into
ChainLearnOfficial:mainfrom
Ranjeet2063:fix/courses-duplicate-api-517

Conversation

@Ranjeet2063

Copy link
Copy Markdown

What

Fixes the issue where CoursesPage was firing duplicate network requests to fetch the course catalog on mount.

How

  • Extracted a new useEnrollments() hook out of useCourses() that only handles fetching and caching the user's enrollments
  • Updated CoursesPage (src/app/courses/page.tsx) to use useEnrollments() instead of useCourses()
  • The page now relies solely on useInfiniteCourses to fetch the catalog grid (which it was already doing) while still successfully fetching the enrollment data needed for the "enrolled" badges.

Closes #517

- Extract `useEnrollments` hook out of `useCourses`
- Use `useEnrollments()` directly on the courses list page instead of `useCourses()`
- Eliminates duplicate `getCourses` network calls since `useInfiniteCourses` already fetches the catalog list

Closes ChainLearnOfficial#517
Copilot AI balanced review requested due to automatic review settings October 2, 2026 19:34
@netlify

netlify Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for chainlearn failed.

Name Link
🔨 Latest commit 7ac5c03
🔍 Latest deploy log https://app.netlify.com/projects/chainlearn/deploys/6ac00fdfb1df9e0008df51f9

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Courses page fires duplicate API requests from useCourses and useInfiniteCourses

2 participants