forked from shadowfacts/Tusker
Fix race condition in Compose screen when loading account
This commit is contained in:
parent
f0b8f92791
commit
a4e7082ab8
|
@ -27,6 +27,8 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
|
||||||
let controller: ComposeController
|
let controller: ComposeController
|
||||||
let mastodonController: MastodonController
|
let mastodonController: MastodonController
|
||||||
|
|
||||||
|
private var cancellables = Set<AnyCancellable>()
|
||||||
|
|
||||||
private var assetPickerCompletion: (@MainActor ([PHPickerResult]) -> Void)?
|
private var assetPickerCompletion: (@MainActor ([PHPickerResult]) -> Void)?
|
||||||
private var drawingCompletion: ((PKDrawing) -> Void)?
|
private var drawingCompletion: ((PKDrawing) -> Void)?
|
||||||
|
|
||||||
|
@ -44,7 +46,6 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
|
||||||
replyContentView: { AnyView(ComposeReplyContentView(status: $0, mastodonController: mastodonController, heightChanged: $1)) },
|
replyContentView: { AnyView(ComposeReplyContentView(status: $0, mastodonController: mastodonController, heightChanged: $1)) },
|
||||||
emojiImageView: { AnyView(CustomEmojiImageView(emoji: $0)) }
|
emojiImageView: { AnyView(CustomEmojiImageView(emoji: $0)) }
|
||||||
)
|
)
|
||||||
controller.currentAccount = mastodonController.account
|
|
||||||
|
|
||||||
self.mastodonController = mastodonController
|
self.mastodonController = mastodonController
|
||||||
|
|
||||||
|
@ -58,6 +59,12 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
|
||||||
|
|
||||||
// set an initial title immediately, in case we're starting ducked
|
// set an initial title immediately, in case we're starting ducked
|
||||||
self.navigationItem.title = self.controller.navigationTitle
|
self.navigationItem.title = self.controller.navigationTitle
|
||||||
|
|
||||||
|
mastodonController.$account
|
||||||
|
.sink { [unowned self] in
|
||||||
|
self.controller.currentAccount = $0
|
||||||
|
}
|
||||||
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder aDecoder: NSCoder) {
|
required init?(coder aDecoder: NSCoder) {
|
||||||
|
|
Loading…
Reference in New Issue