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: Ensure refreshing does not create a gap in the timeline #43

Merged
merged 5 commits into from Sep 14, 2023

Conversation

nikclayton
Copy link
Contributor

The previous code did not handle refreshing correctly; it retained some
of the cache, and tried merge new statuses in to the cache. This does
not work, and resulted in the app creating gaps in the timeline if more
than a page's worth of statuses had appeared since the user last
refreshed (e.g., overnight).

Fix this by treating the on-device cache as disposable, as the Paging3
library intends. On refresh the cached timeline is emptied and replaced
with a fresh page.

This causes a problem for state that is not stored on the server but is
part of a status' viewdata (has the user toggled viewing a piece of
media, expanded a CW, etc).

The previous code tried to work around that by pulling the state out of
the page cache and copying it in to the new statuses. That won't work
when the page cache is being destroyed.

So do it properly -- store the viewdata state in a separate (sparse)
table that contains only rows for statuses that have a non-default
state.

Save changes to the state when the user interacts with a status, and
use the state to ensure that the viewdata for a status in a thread
matches the viewdata for the same status if it is shown on the home
timeline (and vice-versa).

Fixes #16

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
@nikclayton nikclayton added the bug Something isn't working label Sep 14, 2023
@nikclayton nikclayton added this to the Launch 1.1 milestone Sep 14, 2023
@nikclayton nikclayton merged commit 402bcef into pachli:develop Sep 14, 2023
4 checks passed
@nikclayton nikclayton deleted the 16-fix-timeline-gap branch September 14, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Timeline gaps after absence
1 participant