diff --git a/CouchTrackerApp/Shows/Progress/ShowProgressCell.swift b/CouchTrackerApp/Shows/Progress/ShowProgressCell.swift index a82a3060..61171c88 100644 --- a/CouchTrackerApp/Shows/Progress/ShowProgressCell.swift +++ b/CouchTrackerApp/Shows/Progress/ShowProgressCell.swift @@ -1,9 +1,11 @@ import Cartography import CouchTrackerCore +import Kingfisher import RxSwift final class ShowProgressCell: TableViewCell { static let identifier = "ShowProgressCell" + private var imageTask: DownloadTask? private var disposable: Disposable? var presenter: ShowProgressCellPresenter? { @@ -17,10 +19,11 @@ final class ShowProgressCell: TableViewCell { } override func prepareForReuse() { - super.prepareForReuse() - + imageTask?.cancel() posterImageView.image = nil disposable = nil + + super.prepareForReuse() } private func handleViewState(_ viewState: ShowProgressCellViewState) { @@ -41,7 +44,7 @@ final class ShowProgressCell: TableViewCell { } private func showPosterImage(with url: URL) { - posterImageView.kf.setImage(with: url) + imageTask = posterImageView.kf.setImage(with: url) } let posterImageView = UIImageView() diff --git a/CouchTrackerApp/Views/PosterAndTitleCell.swift b/CouchTrackerApp/Views/PosterAndTitleCell.swift index 1ed97583..c7848054 100644 --- a/CouchTrackerApp/Views/PosterAndTitleCell.swift +++ b/CouchTrackerApp/Views/PosterAndTitleCell.swift @@ -4,18 +4,20 @@ import Kingfisher public final class PosterAndTitleCell: CollectionViewCell { public static let identifier = "PosterAndTitleCell" + private var imageTask: DownloadTask? public var presenter: PosterCellPresenter! { didSet { + imageTask?.cancel() posterImageView.image = nil presenter.viewWillAppear() } } public override func prepareForReuse() { - super.prepareForReuse() - + imageTask?.cancel() posterImageView.image = nil + super.prepareForReuse() } public let posterImageView = UIImageView() @@ -58,6 +60,6 @@ extension PosterAndTitleCell: PosterCellView { } public func showPosterImage(with url: URL) { - posterImageView.kf.setImage(with: url) + imageTask = posterImageView.kf.setImage(with: url) } }