Fix restored, ducked Compose screen lacking title

This commit is contained in:
Shadowfacts 2023-04-23 14:27:10 -04:00
parent b782e66a45
commit af5109f86c
2 changed files with 13 additions and 11 deletions

View File

@ -71,6 +71,15 @@ public final class ComposeController: ViewController {
draft.poll == nil || draft.poll!.pollOptions.allSatisfy { !$0.text.isEmpty }
}
public var navigationTitle: String {
if let id = draft.inReplyToID,
let status = fetchStatus(id) {
return "Reply to @\(status.account.acct)"
} else {
return "New Post"
}
}
public init(
draft: Draft,
config: ComposeUIConfig,
@ -281,16 +290,7 @@ public final class ComposeController: ViewController {
Text(error.localizedDescription)
})
.onDisappear(perform: controller.onDisappear)
.navigationTitle(navTitle)
}
private var navTitle: String {
if let id = draft.inReplyToID,
let status = controller.fetchStatus(id) {
return "Reply to @\(status.account.acct)"
} else {
return "New Post"
}
.navigationTitle(controller.navigationTitle)
}
private var mainList: some View {

View File

@ -28,7 +28,6 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
let controller: ComposeController
let mastodonController: MastodonController
private var assetPickerCompletion: (@MainActor ([PHPickerResult]) -> Void)?
private var drawingCompletion: ((PKDrawing) -> Void)?
@ -56,6 +55,9 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
pasteConfiguration = UIPasteConfiguration(forAccepting: DraftAttachment.self)
NotificationCenter.default.addObserver(self, selector: #selector(updateConfig), name: .preferencesChanged, object: nil)
// set an initial title immediately, in case we're starting ducked
self.navigationItem.title = self.controller.navigationTitle
}
required init?(coder aDecoder: NSCoder) {