diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 09a33e997..a1c5e3925 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -377,11 +377,11 @@ extension ProfileViewController { profileHeaderViewController.profileHeaderView.viewModel.viewDidAppear ) .sink { [weak self] (user, _) in - guard let self = self, let user = user else { return } + guard let self, let user else { return } Task { _ = try await self.context.apiService.fetchUser( username: user.username, - domain: user.domain, + domain: user.domainFromAcct, authenticationBox: self.authContext.mastodonAuthenticationBox ) } diff --git a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift index 79715794b..83f94fd22 100644 --- a/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift +++ b/MastodonSDK/Sources/CoreDataStack/Entity/Mastodon/MastodonUser.swift @@ -8,6 +8,7 @@ import CoreData import Foundation +/// See also `CoreDataStack.MastodonUser`, this extension contains several final public class MastodonUser: NSManagedObject { public typealias ID = String diff --git a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift index 191917476..ad9561565 100644 --- a/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift +++ b/MastodonSDK/Sources/MastodonCore/Service/API/APIService+Account.swift @@ -201,8 +201,9 @@ extension APIService { // user let managedObjectContext = self.backgroundManagedObjectContext + var result: MastodonUser? try await managedObjectContext.performChanges { - _ = Persistence.MastodonUser.createOrMerge( + result = Persistence.MastodonUser.createOrMerge( in: managedObjectContext, context: Persistence.MastodonUser.PersistContext( domain: domain, @@ -210,18 +211,9 @@ extension APIService { cache: nil, networkDate: response.networkDate ) - ) - } - var result: MastodonUser? - try await managedObjectContext.perform { - result = Persistence.MastodonUser.fetch(in: managedObjectContext, - context: Persistence.MastodonUser.PersistContext( - domain: domain, - entity: response.value, - cache: nil, - networkDate: response.networkDate - )) + ).user } + return result } }