I have a list of songs in a queue, deleting a single item with a swipe in edit mode shows strange behavior.
The item shortly reappears after deletion, then disappears again.
.onDelete { indexSet in
deleteQueueItemAt(indexSet: indexSet)
}
func deleteQueueItemAt(indexSet: IndexSet) {
musicPlayer.perform { queue in
var itemToRemove : MPMediaItem = MPMediaItem()
indexSet.sorted(by: > ).forEach { (i) in
itemToRemove = queue.items[i + 1]
}
for item in queue.items {
if item.persistentID == itemToRemove.persistentID
{
queue.remove(item)
}
}
} completionHandler: { queue, error in
if error != nil {
print(error!)
}
}
}