musikr: add empty library check
This commit is contained in:
parent
9161b8f777
commit
c3ccb8519e
3 changed files with 5 additions and 1 deletions
|
@ -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()
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in a new issue