Skip to content

Conversation

@toupper
Copy link
Contributor

@toupper toupper commented Sep 15, 2025

Part of WOOMOB-1149

Description

With this PR we add pagination to the POS Orders list, loading more pages when the user scrolls down to the bottom.

This PR will be followed by:

  • Pagination Error
  • Search Pagination

Steps to reproduce

With a site with enough POS Orders (more than the page size 25)

  1. Open the app
  2. Go to POS
  3. Go to POS Orders
  4. Scroll the Orders list to the bottom
  5. See the loading shimmering row
  6. See how it loads a new page

The tests that have been performed

See above.

Images/gif

Screen_Recording_20250917_130720_Woo.Dev.mp4
  • 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.

@toupper toupper marked this pull request as draft September 15, 2025 12:44
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 15, 2025

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit2500934
Direct Downloadwoocommerce-wear-prototype-build-pr14614-2500934.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 15, 2025

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

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit2500934
Direct Downloadwoocommerce-prototype-build-pr14614-2500934.apk

selectedOrderId = state.selectedOrderId,
onOrderSelected = onOrderSelected,
onEndOfOrdersListReached = onEndOfOrdersListReached,
canLoadMore = canLoadMore && state.pullToRefreshState != WooPosPullToRefreshState.Refreshing,
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like that this is equal to

canLoadMore = state.paginationState == WooPosPaginationState.None &&
                        state.pullToRefreshState != WooPosPullToRefreshState.Refreshing && state.pullToRefreshState != WooPosPullToRefreshState.Refreshing

comparing the same twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! Done in 61e72f3

}

if (loadOrdersJob?.isActive == true) {
loadMoreAfterLoadCompletes = true
Copy link
Contributor

Choose a reason for hiding this comment

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

In my opinion, queuing another load of requests overcomplicates things and isn’t worth the added complexity. I don’t believe users expects this behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, I removed that logic in a62305a


private fun loadOrders() {
viewModelScope.launch {
loadOrdersJob?.cancel()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is done already in the search PR so can be reused after taking the changes from there. Also, keep in mind that pagination should also work when the search is on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I will manage that when merging the work on for the Search

…nation

# Conflicts:
#	WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosOrdersDataSource.kt
#	WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosOrdersScreen.kt
#	WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/orders/WooPosOrdersViewModel.kt
@toupper toupper changed the title Feat/woomob 1149 pos historical orders pagination [POS Orders] Pagination Sep 17, 2025
@codecov-commenter
Copy link

codecov-commenter commented Sep 17, 2025

Codecov Report

❌ Patch coverage is 75.71429% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.43%. Comparing base (24ca8cc) to head (2500934).
⚠️ Report is 80 commits behind head on trunk.

Files with missing lines Patch % Lines
.../android/ui/woopos/orders/WooPosOrdersViewModel.kt 69.23% 4 Missing and 12 partials ⚠️
...uxc/network/rest/wpcom/wc/order/OrderRestClient.kt 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #14614      +/-   ##
============================================
+ Coverage     38.42%   38.43%   +0.01%     
- Complexity     9739     9745       +6     
============================================
  Files          2059     2059              
  Lines        115359   115409      +50     
  Branches      15357    15368      +11     
============================================
+ Hits          44328    44363      +35     
- Misses        66922    66926       +4     
- Partials       4109     4120      +11     

☔ 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.

@toupper toupper requested a review from kidinov September 17, 2025 11:29
@toupper toupper marked this pull request as ready for review September 17, 2025 11:29
}

is WooPosOrdersState.Content -> {
val isLoadingMore = state.paginationState == WooPosPaginationState.Loading
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for not commenting on this before. I think the filtering of when to request another page and when to ignore the "end of list" event should be done in the VM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, done in f84c0a8

Copy link
Contributor

@kidinov kidinov Sep 18, 2025

Choose a reason for hiding this comment

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

It’s not quite what I meant. The VM should not expose anything beyond its state. Here is an example - I didn't test it much, but it looks correct

Refactor_pagination_logic_in_WooPosOrdersScreen_and_WooPosOrdersViewModel.patch

Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

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

Thanks for your here!

Overall, everything looks good. The only thing I think needs to be fixed surely is that pagination doesn’t currently work for search cases

@toupper
Copy link
Contributor Author

toupper commented Sep 18, 2025

Thanks for the review @kidinov! As mentioned in the comments, this PR will be followed by:

  • Pagination Error
  • Search Pagination

@toupper toupper added the type: task An internally driven task. label Sep 18, 2025
@toupper toupper added this to the 23.4 milestone Sep 18, 2025
@kidinov kidinov self-requested a review September 18, 2025 12:58
Copy link
Contributor

@kidinov kidinov left a comment

Choose a reason for hiding this comment

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

LGTM! I left one refactoring proposal which I think would be nice to implement, please take a look

@toupper toupper merged commit f788092 into trunk Sep 19, 2025
15 checks passed
@toupper toupper deleted the feat/WOOMOB-1149-pos-historical-orders-pagination branch September 19, 2025 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants