Fix two issues related to share extension (#85)

* Share sheet: fix EnvironmentObject related crash

* Editor: fix the logic of canPost
This commit is contained in:
Jierong Li 2023-01-17 17:09:46 +09:00 committed by GitHub
parent 03749cd89e
commit 96344e2815
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -13,7 +13,8 @@ class ShareViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let client = AppAccountsManager.shared.currentClient
let appAccountsManager = AppAccountsManager.shared
let client = appAccountsManager.currentClient
let account = CurrentAccount.shared
let instance = CurrentInstance.shared
account.setClient(client: client)
@ -26,6 +27,7 @@ class ShareViewController: UIViewController {
if let attachments = item.attachments {
let view = StatusEditorView(mode: .shareExtension(items: attachments))
.environmentObject(UserPreferences.shared)
.environmentObject(appAccountsManager)
.environmentObject(client)
.environmentObject(account)
.environmentObject(theme)

View file

@ -52,7 +52,7 @@ public class StatusEditorViewModel: ObservableObject {
@Published var replyToStatus: Status?
@Published var embededStatus: Status?
var canPost: Bool {
statusText.length > 0 || !selectedMedias.isEmpty
statusText.length > 0 || !mediasImages.isEmpty
}
var shouldDisablePollButton: Bool {