Repository navigation
Conversation
TvProviderWorker only ever deleted rows that left resume/next up and inserted rows for items that had none. Rows that already existed were skipped, so everything they carry - playback position, title, artwork, description - stayed frozen at whatever it was when the row was first created, since convert() only ran for new items. Split the items the server still wants shown into toAdd and toUpdate, and write the current values onto the existing rows via ContentResolver.update(). While grouping the existing rows by internalProviderId, also collapse duplicates: nothing else ever removed them. Two rows sharing one item id are both considered valid by the delete pass and both suppress the insert, so once a duplicate existed it survived every sync forever. Keep the first row and delete the rest.
Launchers order the watch next row by LAST_ENGAGEMENT_TIME_UTC_MILLIS,
and convert() computed that field itself instead of reusing what the row
was already sorted by. Two things went wrong with it:
setLastEngagementTimeUtcMillis(
dto.userData?.lastPlayedDate?.atZone(...)?.toEpochSecond()
?: Date().time,
)
toEpochSecond() returns seconds where the field expects milliseconds, so
every played item collapsed into early 1970. Items without a last played
date - every next up episode that was never started - fell through to
Date().time and were stamped with "now", which put them ahead of
everything the user had actually been watching.
buildCombined() already resolves the right timestamp for each item: the
item's own last played date for resume items, the series' last played
date (via DatePlayedService) for next up items, and sorts by it. Add
buildCombinedWithLastPlayed() which returns those timestamps alongside
the items, and have buildCombined() delegate to it, so existing callers
are unaffected. TvProviderWorker passes the timestamp into convert() and
writes it as epoch millis.
Unknown timestamps now sort last (0L) rather than first, matching what
sortedByDescending does with them in the app.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Currently there is only a "add" and "remove" operation in the TvProviderWorker.
This PR adds a "update" functionality, which rewrites the playback entry on every sync. This makes sure that the displayed progress the tv provider (in my case projectivy) stays consistent with the actual progress in wholphin/jellyfin.
Also the items are grouped by the internalProviderId. This fixes the issue of duplicate entries in the tv provider.
Lastly the sorting by datetime was fixed.
setLastEngagementTimeUtcMillis requires milis, but seconds were provided.
Related issues
#2128
Testing
Testing was done with the following setting:
I have done manual testing for this PR by installing a release build with R8/minify. I added/removed and changed the progress of the watched items to check if they were correctly displayed. All previous problems were fixed and the progress in the tv provider is now correctly synced and equal to the items in the app.
Screenshots
/
AI or LLM usage
The code written in this PR is by AI.
The changes were tested manually by me, like written in the testing-chapter