music: fix genre linker issues

This commit is contained in:
Alexander Capehart 2024-11-25 20:24:06 -07:00
parent c7f4f842f3
commit 9a990096da
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -9,7 +9,7 @@ import org.oxycblt.auxio.music.stack.interpret.model.SongImpl
import org.oxycblt.auxio.music.stack.interpret.prepare.PreGenre
import org.oxycblt.auxio.music.stack.interpret.prepare.PreSong
class GenreTree {
class GenreLinker {
private val tree = mutableMapOf<String?, GenreLink>()
fun register(preSong: Flow<PreSong>): Flow<LinkedSong> = preSong.map {
@ -42,7 +42,9 @@ class GenreTree {
var node: GenreNode
) : Linked<GenreImpl, SongImpl> {
override fun resolve(child: SongImpl): GenreImpl {
return requireNotNull(node.genreImpl) { "Link" }
return requireNotNull(node.genreImpl) { "Genre not resolved yet" }.also {
it.link(child)
}
}
}