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