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
Paging3: Discussion #2913
Paging3: Discussion #2913
Conversation
transacter.transactionWithResult { | ||
val count = countQuery.executeAsOne() | ||
if (count != 0L && key >= count) throw IndexOutOfBoundsException() |
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 had to remove this (https://github.com/cashapp/sqldelight/pull/2219/files#r825447672), consider the following scenario:
You have 3 items from your database. All are currently shown because some column = true
when changing that particular column for instance for the last entry, the item should not be shown any longer since column = false
. This used to work fine in paging2, but now it crashes here.
Removing it just works fine. The item won't be shown and my RecyclerView only has 2 items.
@@ -33,11 +33,13 @@ internal class OffsetQueryPagingSource<RowType : Any>( | |||
override suspend fun load( | |||
params: LoadParams<Long> | |||
): LoadResult<Long, RowType> = withContext(dispatcher) { | |||
val key = when { | |||
params is LoadParams.Refresh -> (params.key ?: 0L) / params.loadSize * params.loadSize |
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.
My Pager Config has a page size of 40. If I change the underlying data of item at key / index 3 and a LoadParams.Refresh
is triggered. With the old behavior, data was reloaded however it was now using offset=3. This caused the recycler view to auto scroll for some reason that I don't understand. Also this wasn't happening with paging2.
After fiddling with it, I found out that when staying in the same offset range (offset=0) as earlier before, my item was instantly updated and there was no scrolling.
Thanks for doing this work - we have to do a similar thing on cash updating to paging3 so I'm going to take a thorough look tomorrow during work to make sure I understand the changes |
@AlecStrong have you had a chance to test this implementation in the cash app? |
I have not |
Superseded by #3396 |
Follow up from:
https://github.com/cashapp/sqldelight/pull/2219/files#r825447672
I'm trying to upgrade from paging2 to paging3 and so far
OffsetQueryPagingSource
hasn't worked for me. With the changes below they do.I'd like to discuss with others if my mental model of how paging should work is wrong or if the current implementation hasn't considered all use cases.
Tests should be failing. First want to discuss the change.