Fix not being able to close draft when automatic save preference is off
This commit is contained in:
parent
cfc69627e5
commit
0d7cc69947
|
@ -135,6 +135,16 @@ public final class ComposeController: ViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MainActor
|
||||||
|
func cancel(deleteDraft: Bool) {
|
||||||
|
if deleteDraft {
|
||||||
|
DraftsManager.shared.remove(draft)
|
||||||
|
} else {
|
||||||
|
DraftsManager.save()
|
||||||
|
}
|
||||||
|
config.dismiss(.cancel)
|
||||||
|
}
|
||||||
|
|
||||||
func postStatus() {
|
func postStatus() {
|
||||||
guard !isPosting,
|
guard !isPosting,
|
||||||
draft.hasContent else {
|
draft.hasContent else {
|
||||||
|
@ -329,6 +339,14 @@ public final class ComposeController: ViewController {
|
||||||
// otherwise all Buttons in the nav bar are made semibold
|
// otherwise all Buttons in the nav bar are made semibold
|
||||||
.font(.system(size: 17, weight: .regular))
|
.font(.system(size: 17, weight: .regular))
|
||||||
}
|
}
|
||||||
|
.confirmationDialog("Are you sure?", isPresented: $controller.isShowingSaveDraftSheet) {
|
||||||
|
Button(action: { controller.cancel(deleteDraft: false) }) {
|
||||||
|
Text("Save Draft")
|
||||||
|
}
|
||||||
|
Button(role: .destructive, action: { controller.cancel(deleteDraft: true) }) {
|
||||||
|
Text("Delete Draft")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
|
|
Loading…
Reference in New Issue