Skip to content

Add product search and pagination - #461

Merged
CherryCIC merged 2 commits into
Cherry-CIC:mainfrom
yusuphjoluwasen:feature/search-pagination-home-cache
Jul 20, 2026
Merged

Add product search and pagination#461
CherryCIC merged 2 commits into
Cherry-CIC:mainfrom
yusuphjoluwasen:feature/search-pagination-home-cache

Conversation

@yusuphjoluwasen

@yusuphjoluwasen yusuphjoluwasen commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add API-backed product search and cursor pagination
  • Separate home feed state from search state so search does not filter or reload home
  • Keep search results, empty, loading, and failure states scoped to the search sheet
  • Add normal home infinite scroll and pull-to-refresh

Summary by CodeRabbit

  • New Features

    • Added paginated product loading with support for search queries.
    • Added debounced product search with suggestions, result loading, and load-more support.
    • Added pull-to-refresh and automatic loading of additional products while scrolling.
    • Added loading indicators for pagination and clearer product loading error states.
  • Bug Fixes

    • Improved handling and display of failed product requests.
    • Prevented outdated search results from replacing newer results.

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@yusuphjoluwasen, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 19 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 075ca58a-5663-4dce-81b6-bdd1b713df8d

📥 Commits

Reviewing files that changed from the base of the PR and between e0d2bdf and 2fd1aa9.

📒 Files selected for processing (1)
  • lib/features/home/home_viewmodel.dart
📝 Walkthrough

Walkthrough

The home product flow now returns paginated results, supports debounced search and incremental loading, exposes refresh behavior, and surfaces API failures. Home and search widgets trigger pagination and render loading, empty, failure, and product-result states, with tests updated for the new contract.

Changes

Home products and search

Layer / File(s) Summary
Repository pagination contract
lib/features/home/home_repository.dart
fetchProducts now accepts pagination and search parameters, returns ProductPage, parses metadata, and reports invalid or failed requests as failures.
Pagination and search state management
lib/features/home/home_viewmodel.dart
HomeViewModel manages home/search state, debouncing, refresh, pagination, stale-request protection, and product de-duplication.
Home and search UI integration
lib/features/home/widgets/*, lib/features/search/widgets/search.dart
Home scrolling and pull-to-refresh invoke view-model actions; search renders product results, loading states, retries, pagination, and navigation.
Repository and screen validation
test/home_repository_test.dart, test/home_screen_mvp_test.dart
Tests cover ProductPage parsing, query forwarding, failures, search visibility, layout, and error UI.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • Cherry-CIC/MVP#443: Overlaps the home screen and dashboard widget changes.
  • Cherry-CIC/MVP#454: Also changes home repository and view-model response and error handling.
  • Cherry-CIC/MVP#458: Couples to the updated home repository contract for home-feed product hydration.

Suggested labels: UI, MVP, Frontend

Suggested reviewers: cherrycic

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding product search with pagination.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
lib/features/home/home_viewmodel.dart (1)

113-134: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Load-more failure can cause repeated failing requests.

On failure, _hasMore and _nextCursor are left unchanged and only a warning is logged. Since HomeScreen calls loadMoreProducts() on every scroll notification while extentAfter < 600, a user who keeps scrolling near the bottom will re-trigger the same failing page fetch repeatedly with no user-visible error. Consider surfacing a retriable error state and/or a short backoff so a failed page isn't hammered.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/features/home/home_viewmodel.dart` around lines 113 - 134, Update
loadMoreProducts to handle failed page fetches with a retriable, user-visible
error state or a short retry backoff, preventing repeated requests while the
scroll position remains near the bottom. Apply this behavior in the result
failure and exception paths while preserving successful pagination updates and
request-sequence checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@lib/features/home/home_viewmodel.dart`:
- Around line 113-134: Update loadMoreProducts to handle failed page fetches
with a retriable, user-visible error state or a short retry backoff, preventing
repeated requests while the scroll position remains near the bottom. Apply this
behavior in the result failure and exception paths while preserving successful
pagination updates and request-sequence checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9f9be2a1-f58f-4e9e-b5d3-9c11b4b5abbb

📥 Commits

Reviewing files that changed from the base of the PR and between 31b2bdd and e0d2bdf.

📒 Files selected for processing (8)
  • lib/features/home/home_repository.dart
  • lib/features/home/home_viewmodel.dart
  • lib/features/home/widgets/dashboard.dart
  • lib/features/home/widgets/dashboard_empty_widget.dart
  • lib/features/home/widgets/home_screen.dart
  • lib/features/search/widgets/search.dart
  • test/home_repository_test.dart
  • test/home_screen_mvp_test.dart

@CherryCIC
CherryCIC self-requested a review July 20, 2026 19:45

@CherryCIC CherryCIC left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Image

I'm happy with this and it looks good.

A future iteration could be useful for also searching charities, but as a basic search this is looking great!

Thank you @yusuphjoluwasen

@CherryCIC
CherryCIC merged commit 48113f0 into Cherry-CIC:main Jul 20, 2026
3 checks passed
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