musikr: re-add playlist rewriting

This commit is contained in:
Alexander Capehart 2024-12-17 12:12:09 -05:00
parent 744097694f
commit b3a598c558
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47

View file

@ -89,7 +89,13 @@ internal data class LibraryImpl(
}
override suspend fun rewritePlaylist(playlist: Playlist, songs: List<Song>): MutableLibrary {
return this
val playlistImpl = requireNotNull(playlistUidMap[playlist.uid]) {
"Playlist to rewrite is not in this library"
}
playlistImpl.core.prePlaylist.handle.rewrite(songs)
val core = NewPlaylistCore(playlistImpl.core.prePlaylist, songs)
val newPlaylist = PlaylistImpl(core)
return copy(playlists = playlists - playlistImpl + newPlaylist)
}
override suspend fun deletePlaylist(playlist: Playlist): MutableLibrary {