summaryrefslogtreecommitdiff
path: root/Sora/Views
diff options
context:
space:
mode:
Diffstat (limited to 'Sora/Views')
-rw-r--r--Sora/Views/Generic/GenericListView.swift13
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)
+ }
}
}