Fix eventually incorrect domain used

This commit is contained in:
Marcus Kida 2023-12-04 11:09:47 +01:00
parent a1cd1690fa
commit 69a92c3d0f
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
3 changed files with 2 additions and 26 deletions

View File

@ -25,19 +25,3 @@ extension DataSourceFacade {
}
}
}
extension DataSourceFacade {
static func author(
managedObjectContext: NSManagedObjectContext,
status: MastodonStatus,
target: StatusTarget
) async -> ManagedObjectRecord<MastodonUser>? {
return try? await managedObjectContext.perform {
return DataSourceFacade.status(managedObjectContext: managedObjectContext, status: status, target: target)
.flatMap { $0.entity.account }
.flatMap {
MastodonUser.findOrFetch(in: managedObjectContext, matching: MastodonUser.predicate(domain: $0.domain ?? "", id: $0.id))?.asRecord
}
}
}
}

View File

@ -276,6 +276,7 @@ extension NotificationTimelineViewController: TableViewControllerNavigateable {
guard let indexPathForSelectedRow = tableView.indexPathForSelectedRow else { return }
guard let diffableDataSource = viewModel.diffableDataSource else { return }
guard let item = diffableDataSource.itemIdentifier(for: indexPathForSelectedRow) else { return }
let domain = authContext.mastodonAuthenticationBox.domain
Task { @MainActor in
switch item {
@ -296,7 +297,7 @@ extension NotificationTimelineViewController: TableViewControllerNavigateable {
} else {
context.managedObjectContext.perform {
let mastodonUserRequest = MastodonUser.sortedFetchRequest
mastodonUserRequest.predicate = MastodonUser.predicate(domain: notification.account.domain ?? "", id: notification.account.id)
mastodonUserRequest.predicate = MastodonUser.predicate(domain: domain, id: notification.account.id)
mastodonUserRequest.fetchLimit = 1
guard let mastodonUser = try? self.context.managedObjectContext.fetch(mastodonUserRequest).first else {
return

View File

@ -142,15 +142,6 @@ extension StatusView {
}
} else {
// B. replyTo status not exist
// let request = MastodonUser.sortedFetchRequest
// request.predicate = MastodonUser.predicate(domain: status.domain, id: inReplyToAccountID)
// if let user = status.managedObjectContext?.safeFetch(request).first {
// // B1. replyTo user exist
// let header = createHeader(name: user.displayNameWithFallback, emojis: user.emojis.asDictionary)
// viewModel.header = header
// } else {
// B2. replyTo user not exist
let header = createHeader(name: nil, emojis: nil)
viewModel.header = header