From 96344e2815c6e8e6da7471dc32f3549ae493bda3 Mon Sep 17 00:00:00 2001 From: Jierong Li Date: Tue, 17 Jan 2023 17:09:46 +0900 Subject: [PATCH] Fix two issues related to share extension (#85) * Share sheet: fix EnvironmentObject related crash * Editor: fix the logic of canPost --- IceCubesShareExtension/ShareViewController.swift | 4 +++- .../Status/Sources/Status/Editor/StatusEditorViewModel.swift | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/IceCubesShareExtension/ShareViewController.swift b/IceCubesShareExtension/ShareViewController.swift index aa27dc39..9528f41e 100644 --- a/IceCubesShareExtension/ShareViewController.swift +++ b/IceCubesShareExtension/ShareViewController.swift @@ -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) diff --git a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift index 46583259..1ac4b356 100644 --- a/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift +++ b/Packages/Status/Sources/Status/Editor/StatusEditorViewModel.swift @@ -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 {