Compose: assign account synchronously if possible

This commit is contained in:
Shadowfacts 2024-08-10 10:39:11 -07:00
parent 727f28e39f
commit 66626c8f62
1 changed files with 6 additions and 1 deletions

View File

@ -50,6 +50,10 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
emojiImageView: { AnyView(CustomEmojiImageView(emoji: $0)) }
)
if let account = mastodonController.account {
controller.currentAccount = account
}
self.mastodonController = mastodonController
super.init(rootView: View(mastodonController: mastodonController, controller: controller))
@ -151,7 +155,8 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
var body: some SwiftUI.View {
ControllerView(controller: { controller })
.task {
if let account = try? await mastodonController.getOwnAccount() {
if controller.currentAccount == nil,
let account = try? await mastodonController.getOwnAccount() {
controller.currentAccount = account
}
}