From 173eda1757880331d79bd4e0f6f8f5fb8bbd4061 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 9 Sep 2023 11:35:46 -0400 Subject: [PATCH] Prevent dismissing compose screen while posting --- .../Sources/ComposeUI/Controllers/ComposeController.swift | 3 ++- Tusker/Screens/Compose/ComposeHostingController.swift | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift index c1d645c0..93682956 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ComposeController.swift @@ -58,7 +58,7 @@ public final class ComposeController: ViewController { private var isDisappearing = false private var userConfirmedDelete = false - var isPosting: Bool { + public var isPosting: Bool { poster != nil } @@ -424,6 +424,7 @@ public final class ComposeController: ViewController { // otherwise all Buttons in the nav bar are made semibold .font(.system(size: 17, weight: .regular)) } + .disabled(controller.isPosting) .confirmationDialog("Are you sure?", isPresented: $controller.isShowingSaveDraftSheet) { // edit drafts can't be saved if draft.editedStatusID == nil { diff --git a/Tusker/Screens/Compose/ComposeHostingController.swift b/Tusker/Screens/Compose/ComposeHostingController.swift index 6259771d..6e8e7580 100644 --- a/Tusker/Screens/Compose/ComposeHostingController.swift +++ b/Tusker/Screens/Compose/ComposeHostingController.swift @@ -144,7 +144,9 @@ class ComposeHostingController: UIHostingController DuckAttemptAction { - if controller.draft.hasContent { + if controller.isPosting { + return .block + } else if controller.draft.hasContent { return .duck } else { return .dismiss