Manos Chorianopoulos

fix history cell image caching

......@@ -15,6 +15,24 @@ class AnalysisItemViewCell: UITableViewCell {
@IBOutlet weak var priceLabel: UILabel!
@IBOutlet weak var subtitleLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.itemImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.itemImage.image = image
}
}
}
else {
self.itemImage.image = nil
}
}
}
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
......@@ -42,7 +60,8 @@ extension AnalysisItemViewCell {
for merchant in merchantList {
if (merchant._uuid == item._merchant_uuid) {
itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
self.postImageURL = merchant._img_preview
titleLabel.text = merchant._admin_name
break;
}
......@@ -76,7 +95,8 @@ extension AnalysisItemViewCell {
for merchant in merchantList {
if (merchant._uuid == couponSetData?.merchant_uuid) {
itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
self.postImageURL = merchant._img_preview
titleLabel.text = merchant._admin_name
break;
}
......