From e7af56a93020343dfa1f2d24a04217fd02be0253 Mon Sep 17 00:00:00 2001 From: Sjmarf <78750526+Sjmarf@users.noreply.github.com> Date: Sun, 5 Jan 2025 15:30:23 +0000 Subject: [PATCH] Fix flair assertion failure (#1572) --- .../Shared/Labels/FullyQualifiedLabelView.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Mlem/App/Views/Shared/Labels/FullyQualifiedLabelView.swift b/Mlem/App/Views/Shared/Labels/FullyQualifiedLabelView.swift index 7396f5991..c67473795 100644 --- a/Mlem/App/Views/Shared/Labels/FullyQualifiedLabelView.swift +++ b/Mlem/App/Views/Shared/Labels/FullyQualifiedLabelView.swift @@ -88,11 +88,22 @@ struct FullyQualifiedLabelView: View { var flairs: [PersonFlair] { guard let person = entity as? any Person else { return [] } return person.flairs( - interactableContext: (commentContext as? any Comment2Providing) ?? (postContext as? any Post2Providing), + interactableContext: interactableContext, communityContext: communityContext ) } + var interactableContext: (any Interactable2Providing)? { + guard let person = entity as? any Person else { return nil } + if let commentContext2 = commentContext as? any Comment2Providing, commentContext2.creator.actorId == person.actorId { + return commentContext2 + } + if let postContext2 = postContext as? any Post2Providing, postContext2.creator.actorId == person.actorId { + return postContext2 + } + return nil + } + var accessibilityLabel: String { guard let entity, let fullName = entity.fullName else { return String(localized: "Loading...") } let flairs = flairs