damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit ba32d15a494987bea6c24a0fbfb5bfba8ae26955
parent b688fa98a5498ebd7d27e59d8709af10e7b88ce2
Author: OlegAba <mail@olegaba.com>
Date:   Thu,  5 Jan 2023 17:45:40 -0500

Refactor large image processor

Changelog-Fixed: Fixed a few issues with avatars not animating

Diffstat:
Mdamus/Views/ProfilePicView.swift | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift @@ -62,7 +62,6 @@ struct InnerProfilePicView: View { .placeholder { _ in Placeholder } - .cacheOriginalImage() .scaleFactor(UIScreen.main.scale) .loadDiskFileSynchronously() .fade(duration: 0.1) @@ -112,17 +111,20 @@ struct LargeImageProcessor: ImageProcessor { let downsampleSize = CGSize(width: 200, height: 200) func process(item: ImageProcessItem, options: KingfisherParsedOptionsInfo) -> KFCrossPlatformImage? { - let downsamplingImageProcessor = DownsamplingImageProcessor(size: downsampleSize) switch item { case .image(let image): - if image.cacheCost > maxSize { - return downsamplingImageProcessor.process(item: item, options: options) + guard let data = image.kf.data(format: .unknown) else { + return nil + } + + if data.count > maxSize { + return KingfisherWrapper.downsampledImage(data: data, to: downsampleSize, scale: options.scaleFactor) } return image case .data(let data): if data.count > maxSize { - return downsamplingImageProcessor.process(item: item, options: options) + return KingfisherWrapper.downsampledImage(data: data, to: downsampleSize, scale: options.scaleFactor) } return KFCrossPlatformImage(data: data) }