Add pagination support for POS local catalog product loading#15509
Conversation
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.
…ests for alignment.
|
|
There was a problem hiding this comment.
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.
...-plugin/src/main/kotlin/org/wordpress/android/fluxc/persistence/dao/pos/WooPosProductsDao.kt
Show resolved
Hide resolved
...rc/main/kotlin/org/wordpress/android/fluxc/store/pos/localcatalog/WooPosLocalCatalogStore.kt
Show resolved
Hide resolved
...ain/kotlin/com/woocommerce/android/ui/woopos/home/items/products/WooPosProductsDataSource.kt
Show resolved
Hide resolved
...ain/kotlin/com/woocommerce/android/ui/woopos/home/items/products/WooPosProductsDataSource.kt
Show resolved
Hide resolved
...main/kotlin/com/woocommerce/android/ui/woopos/home/items/products/WooPosProductsViewModel.kt
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|

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:
getProductsquery toWooPosProductsDaowithLIMIT/OFFSETsupportWooPosLocalCatalogStore.getProducts()WooPosProductsInDbDataSourceto use page-based loading with accumulated results instead of observing all products at onceWooPosProductsViewModelby mapping only newly loaded products when appending pages instead of re-mapping all accumulated productsWOO_POS_LOCAL_CATALOG_FILE_APPROACHfeature flag on debug buildsTest Steps
Before
Screen.Recording.2026-03-11.at.11.24.17.mov
After
Screen.Recording.2026-03-11.at.10.08.21.mov
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.