Local route over UDP

This commit is contained in:
Christoph Hagen
2024-04-22 12:58:49 +02:00
parent 877bba56b4
commit 91af68a44b
7 changed files with 250 additions and 25 deletions

View File

@ -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")
}