Fix missing poll information (IOS-201)

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

View File

@ -284,7 +284,7 @@ public final class ComposeContentViewModel: NSObject, ObservableObject {
contentWarning = status.entity.spoilerText ?? "" contentWarning = status.entity.spoilerText ?? ""
} }
Task { Task {
if let poll = await status.getPoll(in: context.managedObjectContext) { if let poll = await status.getPoll(in: context.managedObjectContext, domain: authContext.mastodonAuthenticationBox.domain) {
isPollActive = !poll.expired isPollActive = !poll.expired
pollMultipleConfigurationOption = poll.multiple pollMultipleConfigurationOption = poll.multiple
if let pollExpiresAt = poll.expiresAt { if let pollExpiresAt = poll.expiresAt {

View File

@ -362,12 +362,13 @@ extension StatusView {
private func configurePoll(status: MastodonStatus) { private func configurePoll(status: MastodonStatus) {
Task { Task {
let status = status.reblog ?? status
guard guard
let context = viewModel.context?.managedObjectContext, let context = viewModel.context?.managedObjectContext,
let poll = await status.getPoll(in: context) let poll = await status.getPoll(in: context, domain: viewModel.authContext?.mastodonAuthenticationBox.domain ?? "")
else { return } else { return }
let status = status.reblog ?? status
viewModel.managedObjects.insert(poll) viewModel.managedObjects.insert(poll)
@ -507,9 +508,8 @@ extension StatusView {
} }
extension MastodonStatus { extension MastodonStatus {
func getPoll(in context: NSManagedObjectContext) async -> Poll? { func getPoll(in context: NSManagedObjectContext, domain: String) async -> Poll? {
guard guard
let domain = entity.account.domain,
let pollId = entity.poll?.id let pollId = entity.poll?.id
else { return nil } else { return nil }
return try? await context.perform { return try? await context.perform {