forked from zelo72/mastodon-ios
fix: image fetch task not reset before reuse issue
This commit is contained in:
parent
292d3e7da6
commit
ab19323bcd
|
@ -266,6 +266,7 @@
|
|||
DB5086BE25CC0D9900C2C187 /* SplashPreference.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB5086BD25CC0D9900C2C187 /* SplashPreference.swift */; };
|
||||
DB51D172262832380062B7A1 /* BlurHashDecode.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB51D170262832380062B7A1 /* BlurHashDecode.swift */; };
|
||||
DB51D173262832380062B7A1 /* BlurHashEncode.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB51D171262832380062B7A1 /* BlurHashEncode.swift */; };
|
||||
DB52D33A26839DD800D43133 /* ImageTask.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB52D33926839DD800D43133 /* ImageTask.swift */; };
|
||||
DB55D33025FB630A0002F825 /* TwitterTextEditor+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB55D32F25FB630A0002F825 /* TwitterTextEditor+String.swift */; };
|
||||
DB59F0FE25EF5D96001F1DAB /* StatusProvider+UITableViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB59F0FD25EF5D96001F1DAB /* StatusProvider+UITableViewDelegate.swift */; };
|
||||
DB59F10425EF5EBC001F1DAB /* TableViewCellHeightCacheableContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = DB59F10325EF5EBC001F1DAB /* TableViewCellHeightCacheableContainer.swift */; };
|
||||
|
@ -883,6 +884,7 @@
|
|||
DB5086BD25CC0D9900C2C187 /* SplashPreference.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplashPreference.swift; sourceTree = "<group>"; };
|
||||
DB51D170262832380062B7A1 /* BlurHashDecode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlurHashDecode.swift; sourceTree = "<group>"; };
|
||||
DB51D171262832380062B7A1 /* BlurHashEncode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlurHashEncode.swift; sourceTree = "<group>"; };
|
||||
DB52D33926839DD800D43133 /* ImageTask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageTask.swift; sourceTree = "<group>"; };
|
||||
DB55D32F25FB630A0002F825 /* TwitterTextEditor+String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "TwitterTextEditor+String.swift"; sourceTree = "<group>"; };
|
||||
DB59F0FD25EF5D96001F1DAB /* StatusProvider+UITableViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "StatusProvider+UITableViewDelegate.swift"; sourceTree = "<group>"; };
|
||||
DB59F10325EF5EBC001F1DAB /* TableViewCellHeightCacheableContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TableViewCellHeightCacheableContainer.swift; sourceTree = "<group>"; };
|
||||
|
@ -2267,6 +2269,7 @@
|
|||
DB6D1B23263684C600ACB481 /* UserDefaults.swift */,
|
||||
DB97131E2666078B00BD1E90 /* Date.swift */,
|
||||
DBAC6489267DC355007FE9FD /* NSDiffableDataSourceSnapshot.swift */,
|
||||
DB52D33926839DD800D43133 /* ImageTask.swift */,
|
||||
);
|
||||
path = Extension;
|
||||
sourceTree = "<group>";
|
||||
|
@ -3260,6 +3263,7 @@
|
|||
DBCBCC012680AF2A000F5B51 /* AsyncHomeTimelineViewModel+Diffable.swift in Sources */,
|
||||
DBCC3B36261440BA0045B23D /* UINavigationController.swift in Sources */,
|
||||
DBB525852612D6DD002F1F29 /* ProfileStatusDashboardMeterView.swift in Sources */,
|
||||
DB52D33A26839DD800D43133 /* ImageTask.swift in Sources */,
|
||||
2D84350525FF858100EECE90 /* UIScrollView.swift in Sources */,
|
||||
DB49A61F25FF32AA00B98345 /* EmojiService+CustomEmojiViewModel.swift in Sources */,
|
||||
2D76316B25C14D4C00929FB9 /* PublicTimelineViewModel.swift in Sources */,
|
||||
|
|
|
@ -685,7 +685,9 @@ extension StatusSection {
|
|||
case .success:
|
||||
statusItemAttribute.isImageLoaded.value = true
|
||||
}
|
||||
}
|
||||
}?
|
||||
.store(in: &cell.statusView.statusMosaicImageViewContainer.imageTasks)
|
||||
|
||||
|
||||
imageView.accessibilityLabel = meta.altText
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// ImageTask.swift
|
||||
// Mastodon
|
||||
//
|
||||
// Created by Cirno MainasuK on 2021-6-24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Nuke
|
||||
|
||||
extension ImageTask {
|
||||
func store(in set: inout Set<ImageTask?>) {
|
||||
set.insert(self)
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
import os.log
|
||||
import func AVFoundation.AVMakeRect
|
||||
import UIKit
|
||||
import Nuke
|
||||
|
||||
protocol MosaicImageViewContainerPresentable: AnyObject {
|
||||
var mosaicImageViewContainer: MosaicImageViewContainer { get }
|
||||
|
@ -23,6 +24,8 @@ 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
|
||||
|
@ -93,6 +96,9 @@ extension MosaicImageViewContainer {
|
|||
extension MosaicImageViewContainer {
|
||||
|
||||
func reset() {
|
||||
imageTasks.forEach { $0?.cancel() }
|
||||
imageTasks.removeAll()
|
||||
|
||||
container.arrangedSubviews.forEach { subview in
|
||||
container.removeArrangedSubview(subview)
|
||||
subview.removeFromSuperview()
|
||||
|
|
Loading…
Reference in New Issue