musikr: compute uid on presong creation
This commit is contained in:
parent
7768d98632
commit
c42ac644eb
3 changed files with 16 additions and 17 deletions
|
@ -55,7 +55,7 @@ private class MusicGraphBuilderImpl : MusicGraph.Builder {
|
||||||
private val playlistVertices = mutableSetOf<PlaylistVertex>()
|
private val playlistVertices = mutableSetOf<PlaylistVertex>()
|
||||||
|
|
||||||
override fun add(preSong: PreSong) {
|
override fun add(preSong: PreSong) {
|
||||||
val uid = preSong.computeUid()
|
val uid = preSong.uid
|
||||||
if (songVertices.containsKey(uid)) {
|
if (songVertices.containsKey(uid)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ internal interface SongCore {
|
||||||
internal class SongImpl(private val handle: SongCore) : Song {
|
internal class SongImpl(private val handle: SongCore) : Song {
|
||||||
private val preSong = handle.preSong
|
private val preSong = handle.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
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.oxycblt.musikr.tag.interpret
|
package org.oxycblt.musikr.tag.interpret
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
@ -53,22 +53,21 @@ internal 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(Music.UID.Item.SONG, it) }
|
||||||
musicBrainzId?.let { Music.UID.musicBrainz(Music.UID.Item.SONG, it) }
|
?: Music.UID.auxio(Music.UID.Item.SONG) {
|
||||||
?: Music.UID.auxio(Music.UID.Item.SONG) {
|
// 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
|
// consistent across music setting changes. Parents are not held up to the
|
||||||
// consistent across music setting changes. Parents are not held up to the
|
// same standard since grouping is already inherently linked to settings.
|
||||||
// same standard since grouping is already inherently linked to settings.
|
update(rawName)
|
||||||
update(rawName)
|
update(preAlbum.rawName)
|
||||||
update(preAlbum.rawName)
|
update(date)
|
||||||
update(date)
|
|
||||||
|
|
||||||
update(track)
|
update(track)
|
||||||
update(disc?.number)
|
update(disc?.number)
|
||||||
|
|
||||||
update(preArtists.map { artist -> artist.rawName })
|
update(preArtists.map { artist -> artist.rawName })
|
||||||
update(preAlbum.preArtists.map { artist -> artist.rawName })
|
update(preAlbum.preArtists.map { artist -> artist.rawName })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal data class PreAlbum(
|
internal data class PreAlbum(
|
||||||
|
|
Loading…
Reference in a new issue