1
0
mirror of git://jb55.com/damus synced 2024-09-20 03:57:06 +00:00

Refactor large image processor

Changelog-Fixed: Fixed a few issues with avatars not animating
This commit is contained in:
OlegAba 2023-01-05 17:45:40 -05:00 committed by William Casarin
parent b688fa98a5
commit ba32d15a49

View File

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