diff --git a/Tusker/Views/Attachments/AttachmentsContainerView.swift b/Tusker/Views/Attachments/AttachmentsContainerView.swift index e8bdc0d7..0e425896 100644 --- a/Tusker/Views/Attachments/AttachmentsContainerView.swift +++ b/Tusker/Views/Attachments/AttachmentsContainerView.swift @@ -51,6 +51,10 @@ class AttachmentsContainerView: UIView { // MARK: - User Interaface func updateUI(status: StatusMO) { + guard self.statusID != status.id else { + return + } + self.statusID = status.id attachments = status.attachments.filter { AttachmentsContainerView.supportedAttachmentTypes.contains($0.kind) } diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index d49265e2..bdfaf09e 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -152,7 +152,7 @@ class BaseStatusTableViewCell: UITableViewCell { updateGrayscaleableUI(account: account, status: status) updateUIForPreferences(account: account, status: status) - cardView.card = status.card + cardView.updateUI(status: status) cardView.isHidden = status.card == nil cardView.navigationDelegate = delegate cardView.actionProvider = delegate diff --git a/Tusker/Views/Status/StatusCardView.swift b/Tusker/Views/Status/StatusCardView.swift index 84cc1775..7bcb8dfa 100644 --- a/Tusker/Views/Status/StatusCardView.swift +++ b/Tusker/Views/Status/StatusCardView.swift @@ -16,13 +16,8 @@ class StatusCardView: UIView { weak var navigationDelegate: TuskerNavigationDelegate? weak var actionProvider: MenuActionProvider? - var card: Card? { - didSet { - if let card = card { - self.updateUI(card: card) - } - } - } + private var statusID: String? + private(set) var card: Card? private let activeBackgroundColor = UIColor.secondarySystemFill private let inactiveBackgroundColor = UIColor.secondarySystemBackground @@ -115,7 +110,17 @@ class StatusCardView: UIView { NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil) } - private func updateUI(card: Card) { + func updateUI(status: StatusMO) { + guard status.id != statusID else { + return + } + self.card = status.card + self.statusID = status.id + + guard let card = status.card else { + return + } + self.imageView.image = nil updateGrayscaleableUI(card: card) diff --git a/Tusker/Views/Status/StatusCollectionViewCell.swift b/Tusker/Views/Status/StatusCollectionViewCell.swift index bc809f14..99b420cc 100644 --- a/Tusker/Views/Status/StatusCollectionViewCell.swift +++ b/Tusker/Views/Status/StatusCollectionViewCell.swift @@ -84,7 +84,7 @@ extension StatusCollectionViewCell { updateUIForPreferences(status: status) contentContainer.contentTextView.setTextFrom(status: status) - contentContainer.cardView.card = status.card + contentContainer.cardView.updateUI(status: status) contentContainer.cardView.isHidden = status.card == nil contentContainer.cardView.navigationDelegate = delegate contentContainer.cardView.actionProvider = delegate