Skip to content

Commit

Permalink
Fixes the blog icons for Atomic Private sites in the reader.
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez committed Apr 8, 2020
1 parent 68ea4bc commit bb7d122
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions WordPress/Classes/ViewRelated/Reader/ReaderCrossPostCell.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import AlamofireImage
import Foundation
import AutomatticTracks
import WordPressShared.WPStyleGuide

open class ReaderCrossPostCell: UITableViewCell {
Expand Down Expand Up @@ -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
}
}

Expand Down

0 comments on commit bb7d122

Please sign in to comment.