Fix draft being deleted when Compose screen ducked

This commit is contained in:
Shadowfacts 2023-04-23 14:27:00 -04:00
parent a1ffb23f0d
commit b782e66a45
2 changed files with 4 additions and 1 deletions

View File

@ -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()

View File

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