music: only compute song uid once
This commit is contained in:
parent
dd3b411beb
commit
e0bbb88e92
3 changed files with 3 additions and 3 deletions
|
@ -85,7 +85,7 @@ class InterpreterImpl @Inject constructor(private val preparer: Preparer) : Inte
|
||||||
val uidMap = mutableMapOf<Music.UID, SongImpl>()
|
val uidMap = mutableMapOf<Music.UID, SongImpl>()
|
||||||
val songs =
|
val songs =
|
||||||
albumLinkedSongs.mapNotNull {
|
albumLinkedSongs.mapNotNull {
|
||||||
val uid = it.preSong.computeUid()
|
val uid = it.preSong.uid
|
||||||
val other = uidMap[uid]
|
val other = uidMap[uid]
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
SongImpl(it)
|
SongImpl(it)
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.oxycblt.auxio.util.update
|
||||||
class SongImpl(linkedSong: LinkedSong) : Song {
|
class SongImpl(linkedSong: LinkedSong) : Song {
|
||||||
private val preSong = linkedSong.preSong
|
private val preSong = linkedSong.preSong
|
||||||
|
|
||||||
override val uid = preSong.computeUid()
|
override val uid = preSong.uid
|
||||||
override val name = preSong.name
|
override val name = preSong.name
|
||||||
override val track = preSong.track
|
override val track = preSong.track
|
||||||
override val disc = preSong.disc
|
override val disc = preSong.disc
|
||||||
|
|
|
@ -52,7 +52,7 @@ data class PreSong(
|
||||||
val preArtists: List<PreArtist>,
|
val preArtists: List<PreArtist>,
|
||||||
val preGenres: List<PreGenre>
|
val preGenres: List<PreGenre>
|
||||||
) {
|
) {
|
||||||
fun computeUid() =
|
val uid =
|
||||||
musicBrainzId?.let { Music.UID.musicBrainz(MusicType.SONGS, it) }
|
musicBrainzId?.let { Music.UID.musicBrainz(MusicType.SONGS, it) }
|
||||||
?: Music.UID.auxio(MusicType.SONGS) {
|
?: Music.UID.auxio(MusicType.SONGS) {
|
||||||
// Song UIDs are based on the raw data without parsing so that they remain
|
// Song UIDs are based on the raw data without parsing so that they remain
|
||||||
|
|
Loading…
Reference in a new issue