diff options
| author | Fuwn <[email protected]> | 2025-09-05 22:38:20 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-05 22:38:20 -0700 |
| commit | 1e98123807359dbc030411fdf533d520b2dc68fc (patch) | |
| tree | 7613c4dd9446b8fa90c3557dd487a47015a09936 | |
| parent | feat: Development commit (diff) | |
| download | sora-testing-1e98123807359dbc030411fdf533d520b2dc68fc.tar.xz sora-testing-1e98123807359dbc030411fdf533d520b2dc68fc.zip | |
feat: Development commit
| -rw-r--r-- | Sora/Views/Generic/GenericListView.swift | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Sora/Views/Generic/GenericListView.swift b/Sora/Views/Generic/GenericListView.swift index 004a278..86559ee 100644 --- a/Sora/Views/Generic/GenericListView.swift +++ b/Sora/Views/Generic/GenericListView.swift @@ -88,7 +88,18 @@ struct GenericListView<T: Identifiable & Hashable & GenericItem>: View { ForEach(sortedFilteredItems, id: \.id) { item in itemButtonContent(item: item) } - .onDelete(perform: removeAction) + .onDelete { offsets in + let itemsToRemove = offsets.compactMap { index in + index < sortedFilteredItems.count ? sortedFilteredItems[index] : nil + } + let originalIndices = IndexSet( + itemsToRemove.compactMap { itemToRemove in + items.firstIndex { $0.id == itemToRemove.id } + } + ) + + removeAction(originalIndices) + } } } |