playback: fix dropped saved state on empty lib

Since ExoPlaybackStateHolder wasn't handling the new "empty
library" case.
This commit is contained in:
Alexander Capehart 2025-01-13 19:23:32 -07:00
parent 847d5aa1fc
commit f28f2dd9f7
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 3 additions and 3 deletions

View file

@ -50,7 +50,7 @@ constructor(
) : PersistenceRepository { ) : PersistenceRepository {
override suspend fun readState(): PlaybackStateManager.SavedState? { override suspend fun readState(): PlaybackStateManager.SavedState? {
val library = musicRepository.library ?: return null val library = musicRepository.library?.takeIf { !it.empty() } ?: return null
val playbackState: PlaybackState val playbackState: PlaybackState
val heapItems: List<QueueHeapItem> val heapItems: List<QueueHeapItem>
val mappingItems: List<QueueShuffledMappingItem> val mappingItems: List<QueueShuffledMappingItem>

View file

@ -147,7 +147,7 @@ class ExoPlaybackStateHolder(
override fun handleDeferred(action: DeferredPlayback): Boolean { override fun handleDeferred(action: DeferredPlayback): Boolean {
val library = val library =
musicRepository.library musicRepository.library?.takeIf { !it.empty() }
// No library, cannot do anything. // No library, cannot do anything.
?: return false ?: return false
@ -524,7 +524,7 @@ class ExoPlaybackStateHolder(
// --- MUSICREPOSITORY METHODS --- // --- MUSICREPOSITORY METHODS ---
override fun onMusicChanges(changes: MusicRepository.Changes) { override fun onMusicChanges(changes: MusicRepository.Changes) {
if (changes.deviceLibrary && musicRepository.library != null) { if (changes.deviceLibrary && musicRepository.library?.takeIf { !it.empty() } != null) {
// We now have a library, see if we have anything we need to do. // We now have a library, see if we have anything we need to do.
L.d("Library obtained, requesting action") L.d("Library obtained, requesting action")
playbackManager.requestAction(this) playbackManager.requestAction(this)