-
Notifications
You must be signed in to change notification settings - Fork 109
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] Adjust pagination height threshold. Fix GhostItemCardView
rendering when no more items.
#14234
base: trunk
Are you sure you want to change the base?
Conversation
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.
Thanks for the work!
I'm not sure if it's connected to this change but something in this behavior breaks after doing pull to refresh:
- Pull to refresh triggers full screen reload, rather than reload of table
- Ghost cells are no longer shown
Simulator.Screen.Recording.-.iPad.Air.11-inch.M2.-.2024-10-30.at.08.34.59.mp4
Thanks for the review!
I just merged trunk and this should be resolved now 😅
That's an interesting case, these will render perfectly fine if we just scroll down, but will stop rendering if we pull-to-refresh, and then scroll down. This seem to happen because when we pull-to-refresh, we load the initial items, and then fetch the next page, but I spent a couple of hours but I seem unable to find a way through that works 100% of the times. When we reach the end of the page, since we do not know if there are more pages, if we pull-to-refresh we either break the GhostItemCardView rendering, or we break the loading state and triggers a full screen reload, or we have to keep the "infinite" loading at the end of the last item🤔 I'm a bit at a lost here, so any advice is appreciated @staskus |
Adding to this, something I will try tomorrow is to compare if the last item fetched on n-1 is same as last item fetched on n, if that's the case we could trigger something like "isLastPage" which would resolve the infinite "loading" loop at the end of scrolling without having to rely on view state. The only issue that I foresee is that it wouldn't update new products added via web by scrolling down, and the merchant would have to pull-to-refresh to see these, so maybe is a compromise we have to take for now. |
We do not need to remove the items since we’re re-setting the list entirely on reload
Alright, this took longer than expected but seems to be fixed with one liner by updating state assuming that there always be more items if we reload:
On a related note, I think we still need to make some improvements on how we handle view state around here that should make future changes more bulletproof |
Thanks for the fixes!
Yes, ideally there should be a stronger relationship with the API that tells us the total number of pages or products. Same with pull to refresh, to understand if there are any updates - if not don't refresh the existing list. Otherwise we need to play around with the view state.
Unfortunately, I'm able to reproduce a similar issue 🤔 When we do pull to refresh, sometimes two identical requests happen at the same time. The first one finishes with a list of new items, and quickly after that a second request finishes. However, since it was the same request there were no unique items, and It happens when ScreenRecording_10-31-2024.14-43-41_1.MP4A few other things I noticed:
|
We save and perform an additional check against the lastScrollPosition before fetching the next page, this avoids unnecessary network calls when we’re scrolling up through already loaded products.
If we pull-to-refresh fast enough, the system might attempt to reload while the state is still loading
Thanks again for you review Povilas!
Good catch, I added an additional check on 117ead6 so we're sure to not perform additional calls when scrolling back up.
This one is tricky, something I added is an additional check to disallow PTR if state is still loading here: b529301, which was possible up until now if we PTR fast enough. But yes, I can see this happening when the list is short enough, since will load the initial items, and also attempt to load the next page since what's in screen triggers the threshold. And as you say, if there are no "new items" coming back, then Screen.Recording.2024-11-01.at.11.23.13.movI think here we need to make one of the compromises we talked about in the project thread: Since the API cannot help us, and as each network call should come back with 100 products (or a good part of them), having a low number of items on screen and this causing the ghost cell not rendering would be a an edge cases and can iterate further as we go. What do you think? |
Part of #14186
Description
This PR addresses 2 items:
GhostItemCardView
would always show at the end of the list when there are no more items to fetch from the remote.Screen.Recording.2024-10-29.at.15.10.05.mov
Testing:
ProductsRemote
'sConstants.productsPerPage
to a lower threshold, like 7 or 10.GhostItemCardView
will appear while loading dataGhostItemCardView
may appear once, but no more after that.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: