forked from shadowfacts/Tusker
Fix attachments/cards flickering in new cells on reconfiguration
This commit is contained in:
parent
1ed218d5e3
commit
3ab82b2dbb
|
@ -51,6 +51,10 @@ class AttachmentsContainerView: UIView {
|
||||||
// MARK: - User Interaface
|
// MARK: - User Interaface
|
||||||
|
|
||||||
func updateUI(status: StatusMO) {
|
func updateUI(status: StatusMO) {
|
||||||
|
guard self.statusID != status.id else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
self.statusID = status.id
|
self.statusID = status.id
|
||||||
attachments = status.attachments.filter { AttachmentsContainerView.supportedAttachmentTypes.contains($0.kind) }
|
attachments = status.attachments.filter { AttachmentsContainerView.supportedAttachmentTypes.contains($0.kind) }
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ class BaseStatusTableViewCell: UITableViewCell {
|
||||||
updateGrayscaleableUI(account: account, status: status)
|
updateGrayscaleableUI(account: account, status: status)
|
||||||
updateUIForPreferences(account: account, status: status)
|
updateUIForPreferences(account: account, status: status)
|
||||||
|
|
||||||
cardView.card = status.card
|
cardView.updateUI(status: status)
|
||||||
cardView.isHidden = status.card == nil
|
cardView.isHidden = status.card == nil
|
||||||
cardView.navigationDelegate = delegate
|
cardView.navigationDelegate = delegate
|
||||||
cardView.actionProvider = delegate
|
cardView.actionProvider = delegate
|
||||||
|
|
|
@ -16,13 +16,8 @@ class StatusCardView: UIView {
|
||||||
weak var navigationDelegate: TuskerNavigationDelegate?
|
weak var navigationDelegate: TuskerNavigationDelegate?
|
||||||
weak var actionProvider: MenuActionProvider?
|
weak var actionProvider: MenuActionProvider?
|
||||||
|
|
||||||
var card: Card? {
|
private var statusID: String?
|
||||||
didSet {
|
private(set) var card: Card?
|
||||||
if let card = card {
|
|
||||||
self.updateUI(card: card)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private let activeBackgroundColor = UIColor.secondarySystemFill
|
private let activeBackgroundColor = UIColor.secondarySystemFill
|
||||||
private let inactiveBackgroundColor = UIColor.secondarySystemBackground
|
private let inactiveBackgroundColor = UIColor.secondarySystemBackground
|
||||||
|
@ -115,7 +110,17 @@ class StatusCardView: UIView {
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil)
|
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
|
self.imageView.image = nil
|
||||||
|
|
||||||
updateGrayscaleableUI(card: card)
|
updateGrayscaleableUI(card: card)
|
||||||
|
|
|
@ -84,7 +84,7 @@ extension StatusCollectionViewCell {
|
||||||
updateUIForPreferences(status: status)
|
updateUIForPreferences(status: status)
|
||||||
contentContainer.contentTextView.setTextFrom(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.isHidden = status.card == nil
|
||||||
contentContainer.cardView.navigationDelegate = delegate
|
contentContainer.cardView.navigationDelegate = delegate
|
||||||
contentContainer.cardView.actionProvider = delegate
|
contentContainer.cardView.actionProvider = delegate
|
||||||
|
|
Loading…
Reference in New Issue