Local route over UDP
This commit is contained in:
@ -2,8 +2,11 @@ import SwiftUI
|
||||
import SwiftData
|
||||
|
||||
struct HistoryView: View {
|
||||
|
||||
@Environment(\.modelContext)
|
||||
private var context
|
||||
|
||||
@Query
|
||||
@Query(sort: \HistoryItem.startDate, order: .reverse)
|
||||
private var items: [HistoryItem] = []
|
||||
|
||||
private var unlockCount: Int {
|
||||
@ -38,7 +41,17 @@ struct HistoryView: View {
|
||||
}
|
||||
ForEach(items) {entry in
|
||||
HistoryListItem(entry: entry)
|
||||
}
|
||||
}.onDelete(perform: { indexSet in
|
||||
let objects = indexSet.map { items[$0] }
|
||||
for object in objects {
|
||||
context.delete(object)
|
||||
}
|
||||
do {
|
||||
try context.save()
|
||||
} catch {
|
||||
print("Failed to save after deleting \(objects.count) object(s): \(error)")
|
||||
}
|
||||
})
|
||||
}
|
||||
.navigationTitle("History")
|
||||
}
|
||||
|
Reference in New Issue
Block a user