From 7929e7530fafdf977b4f4bb8bb81f544473ad4d5 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 26 Jun 2023 21:12:20 -0700 Subject: [PATCH] Fix incorrect context menu preview on filtered post Closes #413 --- .../TimelineStatusCollectionViewCell.swift | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index 1aa606b3..bdf4fa33 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -536,6 +536,21 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti fatalError() } + self.statusState = state + + let reblogStatus: StatusMO? + if let rebloggedStatus = status.reblog { + reblogStatus = status + reblogStatusID = statusID + rebloggerID = status.account.id + + status = rebloggedStatus + } else { + reblogStatus = nil + reblogStatusID = nil + rebloggerID = nil + } + switch filterResult { case .allow: setContentViewMode(.status) @@ -546,6 +561,10 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti attrStr.append(showStr) filteredLabel.attributedText = attrStr setContentViewMode(.filtered) + + // still update id properties, so that info for other methods (e.g., context menus) is correct + self.statusID = status.id + self.accountID = status.account.id return case .hide: fatalError("unreachable") @@ -553,20 +572,11 @@ class TimelineStatusCollectionViewCell: UICollectionViewListCell, StatusCollecti createObservers() - self.statusState = state - var hideTimelineReason = true - if let rebloggedStatus = status.reblog { - reblogStatusID = statusID - rebloggerID = status.account.id - + if let reblogStatus { hideTimelineReason = false - updateRebloggerLabel(reblogger: status.account) - status = rebloggedStatus - } else { - reblogStatusID = nil - rebloggerID = nil + updateRebloggerLabel(reblogger: reblogStatus.account) } if showFollowedHashtags {