forked from shadowfacts/Tusker
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 currentAccount: (any AccountProtocol)?
|
||||||
@Published public var showToolbar = true
|
@Published public var showToolbar = true
|
||||||
|
@Published public var deleteDraftOnDisappear = true
|
||||||
|
|
||||||
@Published var autocompleteController: AutocompleteController!
|
@Published var autocompleteController: AutocompleteController!
|
||||||
@Published var toolbarController: ToolbarController!
|
@Published var toolbarController: ToolbarController!
|
||||||
|
@ -205,7 +206,7 @@ public final class ComposeController: ViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
func onDisappear() {
|
func onDisappear() {
|
||||||
if !draft.hasContent || didPostSuccessfully {
|
if deleteDraftOnDisappear && (!draft.hasContent || didPostSuccessfully) {
|
||||||
DraftsPersistentContainer.shared.viewContext.delete(draft)
|
DraftsPersistentContainer.shared.viewContext.delete(draft)
|
||||||
}
|
}
|
||||||
DraftsPersistentContainer.shared.save()
|
DraftsPersistentContainer.shared.save()
|
||||||
|
|
|
@ -137,6 +137,8 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
|
||||||
// MARK: Duckable
|
// MARK: Duckable
|
||||||
|
|
||||||
func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat) {
|
func duckableViewControllerWillAnimateDuck(withDuration duration: CGFloat, afterDelay delay: CGFloat) {
|
||||||
|
controller.deleteDraftOnDisappear = false
|
||||||
|
|
||||||
withAnimation(.linear(duration: duration).delay(delay)) {
|
withAnimation(.linear(duration: duration).delay(delay)) {
|
||||||
controller.showToolbar = false
|
controller.showToolbar = false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue