Skip to content

Conversation

@nikclayton
Copy link
Contributor

@nikclayton nikclayton commented Sep 14, 2023

The previous code would always fetch the latest statuses when the app
restarts, jumping the user to the top of the home timeline. This is
because state.anchorPosition was null in this case.

Fix this by passing the saved initialKey to CachedTimelineRemoteMediator
and using it to construct a page of statuses around the requested
status.

This restores the user's reading position, and ensures that if the
user is at the top of the list their reading position is not reset
to the second item in the list.

Fixes #41, #42

Continue to copy the previous values for expanded, etc, although this
will only cover the PAGE_SIZE of statuses that are inserted.
Persist status viewdata as a separate StatusViewDataEntity, and join
this with each status when building from the cached timeline.

This allows the user's viewdata choices to persist after the cached
timeline is cleared during a refresh operation.

Add a repository method to save the status viewdata, and call that
from the viewmodel instead of per-viewdata item methods.
- Periodically prune the StatusViewDataEntity table
- Remove the data when an account is logged out
The previous code would always fetch the latest statuses when the app
restarts, jumping the user to the top of the home timeline. This is
because state.anchorPosition was null in this case.

Fix this by passing the saved initialKey to CachedTimelineRemoteMediator
and using it to construct a page of statuses around the requested
status.

This restores the user's reading position, and ensures that if the
user is at the top of the list they're reading position is not reset
to the second item in the list.

Fixes pachli#41, pachli#42
…position

# Conflicts:
#	app/src/main/java/app/pachli/components/timeline/viewmodel/CachedTimelineRemoteMediator.kt
@nikclayton nikclayton merged commit fd7912e into pachli:develop Sep 14, 2023
@nikclayton nikclayton deleted the 42-keep-reading-position branch September 14, 2023 15:19
@nikclayton nikclayton added this to the 1.1 milestone Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Home TL: Already viewed post keeps being treated as a new one on cold starts

1 participant