Fix attachments/cards flickering in new cells on reconfiguration

This commit is contained in:
Shadowfacts 2022-10-08 15:24:12 -04:00
parent 1ed218d5e3
commit 3ab82b2dbb
4 changed files with 19 additions and 10 deletions

View File

@ -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) }

View File

@ -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

View File

@ -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)

View File

@ -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