forked from shadowfacts/Tusker
Fix link card images not loading on Mastodon
This commit is contained in:
parent
3b965b92f2
commit
38a2ebd32b
|
@ -18,7 +18,7 @@ class CachedImageView: UIImageView {
|
||||||
|
|
||||||
override var image: UIImage? {
|
override var image: UIImage? {
|
||||||
didSet {
|
didSet {
|
||||||
fetchTask?.cancel()
|
blurHashTask?.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
Loading…
Reference in New Issue