Skip to content
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

Fix load more #3090

Merged
merged 2 commits into from
Sep 6, 2024
Merged

Fix load more #3090

merged 2 commits into from
Sep 6, 2024

Conversation

atorresveiga
Copy link
Contributor

@atorresveiga atorresveiga commented Sep 6, 2024

Part of: woocommerce/woocommerce-android#12491

Description

Moreover, it seems that afterwards it sometimes stops loading more pages.

This PR fixes an issue that prevented loading more orders (stopped the pagination) when scrolling the orders list after a certain time.

On the previous version of the orders list screen, we always refreshed the orders list when entering the screen. This behavior ensured that we always had fresh data when displaying the screen.

The order pagination saves the current list state in the local DB. Because the list state is saved in the local DB, there could be times when the app saved an intermediary state, for example, Fetching the first page, and the app closed before the final state was saved (can-load-more or fetched). To prevent inconsistent states on the getListState function, a timeout was added to check for more than 1 minute states. If the state was older than 1 minute, the function returned a need-to-refresh state.

On the previous version of the orders list screen, we always refreshed the orders list when entering the screen.

We changed the always refreshed orders list with the background tasks project. Now, we rely more on cached data on the local DB, meaning that final states (can-load-more, fetched) can live longer than 1 minute.

This PR updates the getListState logic so the timeout does not affect final states. The plan is that on Woo, we will implement the logic to expire these final states.

Testing

It is better to test this PR with the Woo PR

@atorresveiga atorresveiga merged commit a77c116 into trunk Sep 6, 2024
13 checks passed
@atorresveiga atorresveiga deleted the issue/12491-fix-load-more branch September 6, 2024 03:19
@@ -351,14 +351,17 @@ class ListStore @Inject constructor(
/**
* A helper function that returns the [ListState] for the given [ListDescriptor].
*/
private fun getListState(listDescriptor: ListDescriptor): ListState {
fun getListState(listDescriptor: ListDescriptor): ListState {
Copy link
Contributor

@malinajirka malinajirka Sep 6, 2024

Choose a reason for hiding this comment

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

⚠️⚠️⚠️ @atorresveiga This code is used by the WPAndroid app as well - have we made sure it works there as expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing this out @malinajirka. I tested the changes on the WPAndroid app and the pagination keeps working as expected

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.

2 participants