Skip to content

Commit

Permalink
fix(local playlist): batch delete
Browse files Browse the repository at this point in the history
  • Loading branch information
z-huang committed Aug 27, 2024
1 parent e4f8cf2 commit 0cbeacf
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,15 @@ fun LocalPlaylistScreen(
val sel = selection.toList()
val sortedSongs = songs.sortedBy { it.map.position }
database.transaction {
val remainSongs = mutableListOf<PlaylistSong>()
sortedSongs.forEach { song ->
if (song.map.id in sel) {
delete(song.map)
} else {
remainSongs.add(song)
}
}
sortedSongs.forEachIndexed { index, song ->
remainSongs.forEachIndexed { index, song ->
if (song.map.position != index) {
update(song.map.copy(position = index))
}
Expand Down

0 comments on commit 0cbeacf

Please sign in to comment.