fix: image may block to fetch issue
This commit is contained in:
parent
a90dac248a
commit
e5e9f83a23
|
@ -675,9 +675,7 @@ extension StatusSection {
|
|||
case .success:
|
||||
statusItemAttribute.isImageLoaded.value = true
|
||||
}
|
||||
}?
|
||||
.store(in: &cell.statusView.statusMosaicImageViewContainer.imageTasks)
|
||||
|
||||
}
|
||||
|
||||
imageView.accessibilityLabel = meta.altText
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@ final class MosaicImageViewContainer: UIView {
|
|||
|
||||
weak var delegate: MosaicImageViewContainerDelegate?
|
||||
|
||||
var imageTasks = Set<ImageTask?>()
|
||||
|
||||
let container = UIStackView()
|
||||
private(set) lazy var imageViews: [UIImageView] = {
|
||||
(0..<4).map { _ -> UIImageView in
|
||||
|
@ -95,9 +93,14 @@ extension MosaicImageViewContainer {
|
|||
|
||||
extension MosaicImageViewContainer {
|
||||
|
||||
func resetImageTask() {
|
||||
imageViews.forEach { imageView in
|
||||
Nuke.cancelRequest(for: imageView)
|
||||
}
|
||||
}
|
||||
|
||||
func reset() {
|
||||
imageTasks.forEach { $0?.cancel() }
|
||||
imageTasks.removeAll()
|
||||
resetImageTask()
|
||||
|
||||
container.arrangedSubviews.forEach { subview in
|
||||
container.removeArrangedSubview(subview)
|
||||
|
|
|
@ -74,7 +74,7 @@ final class StatusTableViewCell: UITableViewCell, StatusCell {
|
|||
override func prepareForReuse() {
|
||||
super.prepareForReuse()
|
||||
selectionStyle = .default
|
||||
statusView.statusMosaicImageViewContainer.reset()
|
||||
statusView.statusMosaicImageViewContainer.resetImageTask()
|
||||
statusView.contentMetaText.textView.isSelectable = false
|
||||
statusView.updateContentWarningDisplay(isHidden: true, animated: false)
|
||||
statusView.statusMosaicImageViewContainer.contentWarningOverlayView.isUserInteractionEnabled = true
|
||||
|
|
|
@ -13,6 +13,7 @@ import CoreDataStack
|
|||
import MastodonSDK
|
||||
import AlamofireImage
|
||||
import AlamofireNetworkActivityIndicator
|
||||
import Nuke
|
||||
|
||||
final class APIService {
|
||||
|
||||
|
@ -35,6 +36,10 @@ final class APIService {
|
|||
// setup cache. 10MB RAM + 50MB Disk
|
||||
URLCache.shared = URLCache(memoryCapacity: 10 * 1024 * 1024, diskCapacity: 50 * 1024 * 1024, diskPath: nil)
|
||||
|
||||
// setup Nuke cache
|
||||
// using LRU disk cache
|
||||
ImagePipeline.shared = ImagePipeline(configuration: .withDataCache)
|
||||
|
||||
// enable network activity manager for AlamofireImage
|
||||
NetworkActivityIndicatorManager.shared.isEnabled = true
|
||||
NetworkActivityIndicatorManager.shared.startDelay = 0.2
|
||||
|
|
Loading…
Reference in New Issue