From 4764116efcf1bd84061a2cb31bbe99be5acf24bd Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Mon, 1 Jan 2024 20:10:00 +0100 Subject: [PATCH] Use account to determine status-visibility (IOS-192) --- .../ComposeContent/ComposeContentViewModel.swift | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift index 9ee1cab64..70f762ffa 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewModel.swift @@ -156,7 +156,7 @@ public final class ComposeContentViewModel: NSObject, ObservableObject { self.visibility = { // default private when user locked var visibility: Mastodon.Entity.Status.Visibility = { - guard let author = authContext.mastodonAuthenticationBox.authentication.user(in: context.managedObjectContext) else { + guard let author = authContext.mastodonAuthenticationBox.authentication.account() else { return .public } return author.locked ? .private : .public @@ -196,7 +196,7 @@ public final class ComposeContentViewModel: NSObject, ObservableObject { case .reply(let record): context.managedObjectContext.performAndWait { let status = record.entity - let author = authContext.mastodonAuthenticationBox.authentication.user(in: context.managedObjectContext) + let author = authContext.mastodonAuthenticationBox.authentication.account() var mentionAccts: [String] = [] if author?.id != status.account.id { @@ -603,12 +603,7 @@ extension ComposeContentViewModel { guard case let .editStatus(status, _) = composeContext else { return nil } // author - let managedObjectContext = self.context.managedObjectContext - var _author: ManagedObjectRecord? - managedObjectContext.performAndWait { - _author = authContext.mastodonAuthenticationBox.authentication.user(in: managedObjectContext)?.asRecord - } - guard let author = _author else { + guard let author = authContext.mastodonAuthenticationBox.authentication.account() else { throw AppError.badAuthentication }