Move poll query code to MastodonStatus

This commit is contained in:
Marcus Kida 2024-01-02 11:35:02 +01:00
parent 54b020ff61
commit c354eeb4d8
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
2 changed files with 12 additions and 12 deletions

View File

@ -58,3 +58,15 @@ public extension Mastodon.Entity.Status {
return MastodonVisibility(rawValue: visibility)
}
}
public extension MastodonStatus {
func getPoll(in context: NSManagedObjectContext, domain: String) async -> Poll? {
guard
let pollId = entity.poll?.id
else { return nil }
return try? await context.perform {
let predicate = Poll.predicate(domain: domain, id: pollId)
return Poll.findOrFetch(in: context, matching: predicate)
}
}
}

View File

@ -535,15 +535,3 @@ extension StatusView {
}
}
extension MastodonStatus {
func getPoll(in context: NSManagedObjectContext, domain: String) async -> Poll? {
guard
let pollId = entity.poll?.id
else { return nil }
return try? await context.perform {
let predicate = Poll.predicate(domain: domain, id: pollId)
return Poll.findOrFetch(in: context, matching: predicate)
}
}
}