Fix cap deletion
This commit is contained in:
parent
403ab1dee5
commit
300c1849fb
@ -295,7 +295,7 @@ struct ContentView: View {
|
||||
.alert(Text("Delete cap"),
|
||||
isPresented: $showDeleteCapAlert,
|
||||
actions: {
|
||||
Button("Delete", role: .destructive, action: saveNewCapName)
|
||||
Button("Delete", role: .destructive, action: startDeleteCap)
|
||||
Button("Cancel", role: .cancel, action: {})
|
||||
}, message: {
|
||||
Text("Confirm the deletion of cap \(selectedCapId ?? 0)")
|
||||
@ -420,12 +420,16 @@ struct ContentView: View {
|
||||
|
||||
private func startDeleteCap() {
|
||||
guard let cap = selectedCapId else {
|
||||
print("No cap to delete")
|
||||
return
|
||||
}
|
||||
Task {
|
||||
print("Deleting cap \(cap)")
|
||||
guard await database.delete(cap: cap) else {
|
||||
print("Failed to delete cap \(cap)")
|
||||
return
|
||||
}
|
||||
print("Deleted cap \(cap)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -800,7 +800,9 @@ final class Database: ObservableObject {
|
||||
// Delete cached images
|
||||
images.removeCachedImages(for: cap)
|
||||
// Delete cap
|
||||
caps[cap] = nil
|
||||
DispatchQueue.main.async {
|
||||
self.caps[cap] = nil
|
||||
}
|
||||
log("Deleted cap \(cap)")
|
||||
return true
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user