Fix race condition in Compose screen when loading account

This commit is contained in:
Shadowfacts 2023-05-28 22:28:41 -07:00
parent f0b8f92791
commit a4e7082ab8
1 changed files with 8 additions and 1 deletions

View File

@ -27,6 +27,8 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
let controller: ComposeController
let mastodonController: MastodonController
private var cancellables = Set<AnyCancellable>()
private var assetPickerCompletion: (@MainActor ([PHPickerResult]) -> Void)?
private var drawingCompletion: ((PKDrawing) -> Void)?
@ -44,7 +46,6 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
replyContentView: { AnyView(ComposeReplyContentView(status: $0, mastodonController: mastodonController, heightChanged: $1)) },
emojiImageView: { AnyView(CustomEmojiImageView(emoji: $0)) }
)
controller.currentAccount = mastodonController.account
self.mastodonController = mastodonController
@ -58,6 +59,12 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
// set an initial title immediately, in case we're starting ducked
self.navigationItem.title = self.controller.navigationTitle
mastodonController.$account
.sink { [unowned self] in
self.controller.currentAccount = $0
}
.store(in: &cancellables)
}
required init?(coder aDecoder: NSCoder) {