Skip to content

Commit

Permalink
Use correct domain to find users
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitschlag committed Nov 4, 2023
1 parent 3fc2793 commit 77bf1ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Mastodon/Scene/Profile/ProfileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,27 +201,19 @@ 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,
entity: response.value,
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
}
}

0 comments on commit 77bf1ab

Please sign in to comment.