feat: infinite scroll on course listing pages - #220
Merged
jobbykings merged 1 commit intoJul 24, 2026
Conversation
- Add useInfiniteScroll hook (IntersectionObserver sentinel pattern) - Add useVirtualList hook for windowed rendering on large datasets - Add useScrollRestoration hook (sessionStorage, Next.js pathname-keyed) - Add InfiniteScrollList component with loading spinner, empty state, error state with retry, and end-of-list indicator - Rewrite CourseGrid to use InfiniteScrollList; remove Load More button - Add GET /api/courses listing endpoint with cursor + offset pagination - Add discoveryApi.listCourses() with CourseListParams/CourseListResponse Closes #<issue-number>
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
Replace traditional pagination with IntersectionObserver-based infinite scroll on the course listing page for a smoother browsing experience.
Changes
New hooks
useInfiniteScroll— attaches an IntersectionObserver to a sentinel element at the bottom of the list; firesonLoadMorewhen it enters the viewport (with 300 px pre-load margin). Guards against duplicate calls while a fetch is in flight.useVirtualList— windowed rendering for large datasets; only renders the visible slice ± overscan buffer, reducing DOM nodes significantly.useScrollRestoration— persists scroll position tosessionStorage, keyed by Next.js pathname or a custom key, and restores it on remount (e.g. navigating back to the listing).New component
InfiniteScrollList— composes the three hooks above. Includes:Updated files
CourseGrid.tsx— removes the old "Load more" button; now drivesInfiniteScrollListwith inline search, sort, and category controls.discoveryApi.ts— addslistCourses()withCourseListParams/CourseListResponsetypes supporting cursor-based pagination.backend/src/routes/courses.js— addsGET /api/courseslisting endpoint supporting both cursor (?cursor=<token>) and offset (?page=2) pagination. Validated via Joi +validateRequestSchema. Returns{ items, total, page, limit, hasMore, nextCursor }.What was tested
npx tsc --noEmit --skipLibCheckpasses with zero errors on all new/modified files.node --check backend/src/routes/courses.jspasses.Labels
area: frontendperformanceenhancementpriority: mediumcloses #196