-
Notifications
You must be signed in to change notification settings - Fork 497
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
else -> params.key ?: 0L | ||
} | ||
try { | ||
val key = params.key ?: 0L | ||
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 commentThe 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 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 | ||
|
||
|
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.