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

Paging3: Discussion #2913

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

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.

else -> params.key ?: 0L
}
try {
val key = params.key ?: 0L
transacter.transactionWithResult {
val count = countQuery.executeAsOne()
if (count != 0L && key >= count) throw IndexOutOfBoundsException()
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 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.


val loadSize = if (key < 0) params.loadSize + key else params.loadSize

Expand Down