Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 17, 2026

Addresses code review feedback on pagination implementation and naming conventions in the home search module.

Pagination Logic

  • Track hasMoreUsers and hasMoreProjects states to prevent fetching when API returns fewer than PAGE_SIZE items
  • Add loading checks to prevent duplicate concurrent requests
  • Applied to 4 pagination locations: search projects/users, search sidebar users, home content projects

Before:

endReached={() => {
  const nextPage = Math.floor(projects.length / 10) + 1;
  fetchProjects(searchTerm, nextPage);
}}

After:

endReached={() => {
  if (!isLoadingProjects && hasMoreProjects) {
    const nextPage = Math.floor(projects.length / PAGE_SIZE) + 1;
    fetchProjects(searchTerm, nextPage);
  }
}}

Code Quality

  • Extract PAGE_SIZE = 10 constant, use across 8 pagination locations
  • Type activeModule as 'search' | 'home' instead of string
  • Rename HOME_ROUTEShomeRoutes per camelCase convention
  • Remove unnecessary setTrendingProjects from useCallback dependencies

State Management

  • Reset users state when clearing search to prevent stale data
  • Simplify handleSearchChange - navigation only on submit/clear, not every keystroke

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
code-a2z Ready Ready Preview, Comment Jan 17, 2026 7:21am
code-a2z-server Ready Ready Preview, Comment Jan 17, 2026 7:21am

Co-authored-by: Avdhesh-Varshney <114330097+Avdhesh-Varshney@users.noreply.github.com>
Co-authored-by: Avdhesh-Varshney <114330097+Avdhesh-Varshney@users.noreply.github.com>
Co-authored-by: Avdhesh-Varshney <114330097+Avdhesh-Varshney@users.noreply.github.com>
Copilot AI changed the title [WIP] Update search functionality for projects on home page Fix pagination logic and extract PAGE_SIZE constant Jan 17, 2026
@Avdhesh-Varshney
Copy link
Collaborator

@copilot Thanks. But not merging

@Avdhesh-Varshney Avdhesh-Varshney deleted the copilot/sub-pr-1350 branch January 18, 2026 17:15
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