Fix link card images not loading on Mastodon

This commit is contained in:
Shadowfacts 2023-05-14 16:24:54 -04:00
parent 3b965b92f2
commit 38a2ebd32b
2 changed files with 1 additions and 33 deletions

View File

@ -18,7 +18,7 @@ class CachedImageView: UIImageView {
override var image: UIImage? { override var image: UIImage? {
didSet { didSet {
fetchTask?.cancel() blurHashTask?.cancel()
} }
} }

View File

@ -199,38 +199,6 @@ class StatusCardView: UIView {
} }
} }
private func loadBlurHash() {
guard let card = card, let hash = card.blurhash else { return }
AttachmentView.queue.async { [weak self] in
guard let self = self else { return }
let size: CGSize
if let width = card.width, let height = card.height {
let aspectRatio = CGFloat(width) / CGFloat(height)
if aspectRatio > 1 {
size = CGSize(width: 32, height: 32 / aspectRatio)
} else {
size = CGSize(width: 32 * aspectRatio, height: 32)
}
} else {
size = CGSize(width: 32, height: 32)
}
guard let preview = UIImage(blurHash: hash, size: size) else {
return
}
DispatchQueue.main.async { [weak self] in
guard let self = self,
self.card?.url == card.url,
self.imageView.image == nil else { return }
self.imageView.image = preview
}
}
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
hStack.backgroundColor = activeBackgroundColor hStack.backgroundColor = activeBackgroundColor
setNeedsDisplay() setNeedsDisplay()