Refresh most-recent sort on book playback - #1587
sashplatonov wants to merge 1 commit into
Conversation
|
Hi @sashplatonov ! I saw this issue and I think it was solved in this PR ( #1582 ), the problem is that AppStore reviews are taking too long now, so v5.22.0 is stuck in waiting for review, I'll revisit this PR once v5.22.0 is out |
|
following up on this @sashplatonov , can you double check on v5.22.0 which is now out on the AppStore and see if the issue still happens? |
|
@GianniCarlo Sorting from #1582 works as expected: choosing "Most recent", "Title", or "File name" updates the order immediately and keeps it after restart. There’s just one thing left: This PR fixes exactly that: it refreshes the list once when playback starts, while keeping the current scroll position. So with v5.22.0 + this PR, Most recent becomes fully live, if that makes sense to you |
Purpose
When the library is sorted by Most recent, the order comes directly from
lastPlayDatein the fetch request.Starting playback updates
lastPlayDate, but the visible list is not fetched again. Because of that, the book the user just started does not move to the top until the screen is reopened or manually refreshed.This change refreshes the Most recent list when playback starts, while keeping the current scroll position
Approach
ItemListView.swift.bookPlayed.mostRecent.ItemListViewModel.swiftreloadItemsPreservingOffset().ItemListViewModelReloadTests.swiftreloadItems()behavior..bookPlayedis used intentionally instead of.bookPlayingor playback progress updates.lastPlayDateis updated every second during playback, so reacting to those events would constantly re-fetch and reorder the list. Refreshing once when playback starts is enough.Things to be aware of / Things to focus on
reloadItemsPreservingOffset()currently setscanLoadMorebased on whether the fetch returned exactly the requested limit. At a page boundary, a re-sort could theoretically make the returned window smaller and stop pagination early..bookPlayedalso fires when autoplay starts the next book. This is expected and keeps that book near the top as well.lastPlayDateis already covered bytestMostRecentReflectsPlaybackImmediately. The new tests focus on the ViewModel reload behavior and pagination state.