musikr: add empty library check

This commit is contained in:
Alexander Capehart 2025-01-01 16:10:34 -07:00
parent 9161b8f777
commit c3ccb8519e
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 5 additions and 1 deletions

View file

@ -149,7 +149,7 @@ private class HomeGeneratorImpl(
}
override fun empty() =
musicRepository.library == null
musicRepository.library?.empty() ?: true
override fun songs() =
musicRepository.library?.let { listSettings.songSort.songs(it.songs) } ?: emptyList()

View file

@ -27,6 +27,8 @@ interface Library {
val genres: Collection<Genre>
val playlists: Collection<Playlist>
fun empty(): Boolean
fun findSong(uid: Music.UID): Song?
fun findSongByPath(path: Path): Song?

View file

@ -42,6 +42,8 @@ internal data class LibraryImpl(
private val genreUidMap = genres.associateBy { it.uid }
private val playlistUidMap = playlists.associateBy { it.uid }
override fun empty() = songs.isEmpty()
override fun findSong(uid: Music.UID) = songUidMap[uid]
override fun findSongByPath(path: Path) = songs.find { it.path == path }