Fix draft being deleted when Compose screen ducked
This commit is contained in:
parent
a1ffb23f0d
commit
b782e66a45
|
@ -29,6 +29,7 @@ public final class ComposeController: ViewController {
|
|||
|
||||
@Published public var currentAccount: (any AccountProtocol)?
|
||||
@Published public var showToolbar = true
|
||||
@Published public var deleteDraftOnDisappear = true
|
||||
|
||||
@Published var autocompleteController: AutocompleteController!
|
||||
@Published var toolbarController: ToolbarController!
|
||||
|
@ -205,7 +206,7 @@ public final class ComposeController: ViewController {
|
|||
}
|
||||
|
||||
func onDisappear() {
|
||||
if !draft.hasContent || didPostSuccessfully {
|
||||
if deleteDraftOnDisappear && (!draft.hasContent || didPostSuccessfully) {
|
||||
DraftsPersistentContainer.shared.viewContext.delete(draft)
|
||||
}
|
||||
DraftsPersistentContainer.shared.save()
|
||||
|
|
|
@ -137,6 +137,8 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
|
|||
// MARK: Duckable
|
||||
|
||||
func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat) {
|
||||
controller.deleteDraftOnDisappear = false
|
||||
|
||||
withAnimation(.linear(duration: duration).delay(delay)) {
|
||||
controller.showToolbar = false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue