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: Scroll and restore position correctly in Home and Notifications #1240

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

nikclayton
Copy link
Contributor

These are cached timelines, backed by Room. Room requires the PagingConfig to have enablePlaceholders = true. Otherwise the list is corrupted when scrolling down the list and paging in new items.

To restore the user's reading position correctly in the UI, wait for the adapter to emit the very first page. Combine this with the user's refresh key, and the number of placeholders in the page, to scroll the user to the correct place in the list.

To make all this work, ensure that Room loads a large enough page of data around the refresh key (in the initialKey calculation).

These are cached timelines, backed by Room. Room **requires** the
`PagingConfig` to have `enablePlaceholders = true`. Otherwise the list
is corrupted when scrolling down the list and paging in new items.

To restore the user's reading position correctly in the UI, wait for
the adapter to emit the very first page. Combine this with the user's
refresh key, and the number of placeholders in the page, to scroll the
user to the correct place in the list.

To make all this work, ensure that Room loads a large enough page of
data around the refresh key (in the `initialKey` calculation).
@nikclayton nikclayton merged commit 0a42ab0 into pachli:main Jan 28, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant