-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Woo POS] Improve next page trigger #14827
base: trunk
Are you sure you want to change the base?
Conversation
Previously we tracked the scroll position and compared it to a threshold based on view height. This resulted in loading the next page whenever the view is scrolled. This changes the approach to show the loading cell whenever we get to the bottom of the list, as long as there are still pages to load. When the loading cell appears, which with the move to LazyVStack is only when it’s scrolled in to view, we start the next page fetch request.
This avoids us calling `loadNextItems` for the root list when a child list is scrolled to the bottom. It also lays the groundwork for calling the correct next item function when we add pagination support.
Generated by 🚫 Danger |
📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well for stores with partial first page and multi-page products I will comment about my thoughts on the infinite scroll separately in #14833. This PR is good to go.
case parent(POSItem) | ||
} | ||
|
||
@Environment(\.floatingControlAreaSize) var floatingControlAreaSize: CGSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this could be private?
@Environment(\.floatingControlAreaSize) var floatingControlAreaSize: CGSize | |
@Environment(\.floatingControlAreaSize) private var floatingControlAreaSize: CGSize |
guard case .root = node else { return } | ||
Task { await posModel.loadNextItems() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this is where we'll trigger the child item next page load as well. Do you plan to add a different loadNextItems
given a parent node, or add a parameter to loadNextItems
with the parent item?
itemStates: [:])) | ||
} else { | ||
let itemStates = itemsViewState.itemsStack.itemStates | ||
.filter { allItems.contains($0.key) } | ||
itemsViewState = .init(containerState: .content, | ||
itemsStack: ItemsStackState(root: .loaded(allItems), | ||
itemsStack: ItemsStackState(root: .loaded(allItems, hasMoreItems: pagedItems.hasMorePages), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe can have a test case for this when pagedItems.hasMorePages
is true
, if not already? Asking because I was seeing all hasMoreItems: false
in the PointOfSaleItemsControllerTests
diffs.
Version |
Part of: #14696
Merge after: #14818
Description
This PR simplifies and improves the trigger for
loadNextPage
on POS item lists. This is preliminary work before adding pagination support for variation lists. The root and child lists also now use the sameItemList
component, which contains everything it needs to show the scrollview and its content.Previously we tracked the scroll position and compared it to a threshold based on view height. This resulted in loading the next page whenever the view is scrolled.
Now we show the loading cell whenever we get to the bottom of the list, as long as there are still pages to load.
When the loading cell appears, we start the next page fetch request.
Steps to reproduce
Set the page size for
ProductsRemote.loadProductsForPointOfSale
to something small enough that you can see multiple pages loading, but large enough that the page more than fills the screen. I use 10.Open the POS and check that you can load multiple pages.
Observe network requests and check that we don't make any extra requests.
Breakpoint in
loadNextItems
to see that it's only called when expected.Check that the new page is _only_loaded when the bottom of the list content is scrolled in to view.
Check that variation lists don't trigger any requests. This is preparatory work for variation pagination support.
Testing information
N.B. If you test this with a very small page size, it won't work, because the loading cell doesn't disappear and reappear between load events, but for realistic page sizes (10+) it works well.
This fixes a bug where scrolling any amount on the list, even if it's not at the end, would result in a next page load.
RELEASE-NOTES.txt
if necessary.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: