From bb7d122e8b23edc75c1cea27bdc143d6ef3204e3 Mon Sep 17 00:00:00 2001 From: Diego Rey Mendez Date: Wed, 8 Apr 2020 17:38:24 -0300 Subject: [PATCH] Fixes the blog icons for Atomic Private sites in the reader. --- .../Reader/ReaderCrossPostCell.swift | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Reader/ReaderCrossPostCell.swift b/WordPress/Classes/ViewRelated/Reader/ReaderCrossPostCell.swift index 9d268b7ac65f..deb3e25840b5 100644 --- a/WordPress/Classes/ViewRelated/Reader/ReaderCrossPostCell.swift +++ b/WordPress/Classes/ViewRelated/Reader/ReaderCrossPostCell.swift @@ -1,4 +1,6 @@ +import AlamofireImage import Foundation +import AutomatticTracks import WordPressShared.WPStyleGuide open class ReaderCrossPostCell: UITableViewCell { @@ -90,11 +92,23 @@ open class ReaderCrossPostCell: UITableViewCell { let placeholder = UIImage(named: blavatarPlaceholder) let size = blavatarImageView.frame.size.width * UIScreen.main.scale - let url = contentProvider?.siteIconForDisplay(ofSize: Int(size)) - if url != nil { - blavatarImageView.downloadImage(from: url, placeholderImage: placeholder) - } else { - blavatarImageView.image = placeholder + + guard let contentProvider = contentProvider, + let url = contentProvider.siteIconForDisplay(ofSize: Int(size)) else { + blavatarImageView.image = placeholder + return + } + + let host = MediaHost(with: contentProvider) { error in + CrashLogging.logError(error) + } + + let mediaAuthenticator = MediaRequestAuthenticator() + mediaAuthenticator.authenticatedRequest(for: url, from: host, onComplete: { [weak self] request in + self?.blavatarImageView.af_setImage(withURLRequest: request, placeholderImage: placeholder) + }) { [weak self] error in + CrashLogging.logError(error) + self?.blavatarImageView.image = placeholder } }