Skip to content

Add pagination support for POS local catalog product loading#15509

Merged
samiuelson merged 11 commits intotrunkfrom
woomob-2453-woo-pos-loading-products-takes-a-while-on-large-store
Mar 12, 2026
Merged

Add pagination support for POS local catalog product loading#15509
samiuelson merged 11 commits intotrunkfrom
woomob-2453-woo-pos-loading-products-takes-a-while-on-large-store

Conversation

@malinajirka
Copy link
Copy Markdown
Contributor

@malinajirka malinajirka commented Mar 10, 2026

WOOMOB-2453

Description

On stores with large catalogs, loading all POS products from the local database at once caused a noticable delay when opening the POS. This PR adds pagination support to the local catalog data source so products are loaded in pages of 25, matching the remote data source behavior.

Eventually, when we remove the hybrid/remote sync approach, we can move back to the more reliable room-observable approach. However, at the moment, it'd require significant changes to the shared data source interface which are not worth it, considering we'll remove it in a few months.

Key changes:

  • Added a paginated getProducts query to WooPosProductsDao with LIMIT/OFFSET support
  • Exposed paginated product fetching via WooPosLocalCatalogStore.getProducts()
  • Refactored WooPosProductsInDbDataSource to use page-based loading with accumulated results instead of observing all products at once
  • Fixed lag in WooPosProductsViewModel by mapping only newly loaded products when appending pages instead of re-mapping all accumulated products
  • Enabled WOO_POS_LOCAL_CATALOG_FILE_APPROACH feature flag on debug builds
  • Triggered product reload after successful pull-to-refresh sync

Test Steps

  1. Enable the local catalog file approach (debug builds only)
  2. Open POS on a store with a large product catalog (50+ products)
  3. Scroll through the product list — double-check all products load
  4. Pull to refresh — products should reload correctly
  5. Verify pagination loads more products as you scroll down

Before

Screen.Recording.2026-03-11.at.11.24.17.mov

After

Screen.Recording.2026-03-11.at.10.08.21.mov
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

Introduces a new paginated query for products in `WooPosProductsDao` and corresponding logic in `WooPosLocalCatalogStore` to fetch a limited number of products with offsets.
Update `WooPosProductsInDbDataSource` to support paginated product loading with offset management.
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Mar 10, 2026

App Icon📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Build Number734
Version24.3-rc-3
Application IDcom.woocommerce.android.prealpha
Commit1acbeae
Installation URL0n0i3lqsqb1eo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds pagination to POS local-catalog product loading to avoid UI lag on large catalogs, aligning local DB behavior with the existing remote paged loading approach.

Changes:

  • Added a paginated Room DAO query (LIMIT/OFFSET) and store API to fetch POS-supported products from the local DB.
  • Refactored the local-DB products data source to load/accumulate products page-by-page (25/page) instead of observing the entire table.
  • Optimized product list pagination in the ViewModel by mapping only newly appended items and reloading products after successful pull-to-refresh sync; enabled a related feature flag in debug builds.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/store/pos/localcatalog/WooPosLocalCatalogStore.kt Exposes paginated local product fetching via getProducts()
libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc/persistence/dao/pos/WooPosProductsDao.kt Adds paginated getProducts Room query with filtering + ordering
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/products/WooPosProductsDataSource.kt Refactors local DB data source to page/accumulate products and report hasMoreProductsPages
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/home/items/products/WooPosProductsViewModel.kt Appends only newly loaded products on pagination; reloads products after PTR success
WooCommerce/src/test/kotlin/com/woocommerce/android/ui/woopos/home/items/products/WooPosProductsInDbDataSourceTest.kt Updates/extends tests to cover paged loading and accumulation
WooCommerce/src/main/kotlin/com/woocommerce/android/util/FeatureFlag.kt Enables WOO_POS_LOCAL_CATALOG_FILE_APPROACH default for debug builds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@malinajirka malinajirka requested a review from samiuelson March 11, 2026 08:14
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.70588% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.56%. Comparing base (ecb8a65) to head (1acbeae).
⚠️ Report is 155 commits behind head on trunk.

Files with missing lines Patch % Lines
.../store/pos/localcatalog/WooPosLocalCatalogStore.kt 0.00% 10 Missing ⚠️
...os/home/items/products/WooPosProductsDataSource.kt 83.33% 1 Missing and 4 partials ⚠️
...pos/home/items/products/WooPosProductsViewModel.kt 70.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##              trunk   #15509   +/-   ##
=========================================
  Coverage     39.55%   39.56%           
  Complexity    11235    11235           
=========================================
  Files          2252     2252           
  Lines        129662   129701   +39     
  Branches      18165    18172    +7     
=========================================
+ Hits          51290    51313   +23     
- Misses        73134    73146   +12     
- Partials       5238     5242    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samiuelson samiuelson self-assigned this Mar 12, 2026
Copy link
Copy Markdown
Contributor

@samiuelson samiuelson left a comment

Choose a reason for hiding this comment

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

LGTM!

@samiuelson samiuelson merged commit 6612892 into trunk Mar 12, 2026
19 checks passed
@samiuelson samiuelson deleted the woomob-2453-woo-pos-loading-products-takes-a-while-on-large-store branch March 12, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants