Leverage new avatarImage function from ArticleUtilities to reduce code duplication between macOS and iOS
This commit is contained in:
parent
5b1c0485c5
commit
ea55aa5bef
|
@ -768,44 +768,12 @@ extension TimelineViewController: NSTableViewDelegate {
|
||||||
private func configureTimelineCell(_ cell: TimelineTableCellView, article: Article) {
|
private func configureTimelineCell(_ cell: TimelineTableCellView, article: Article) {
|
||||||
cell.objectValue = article
|
cell.objectValue = article
|
||||||
|
|
||||||
let avatar = avatarFor(article)
|
let avatar = article.avatarImage()
|
||||||
let featuredImage = featuredImageFor(article)
|
let featuredImage = featuredImageFor(article)
|
||||||
|
|
||||||
cell.cellData = TimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, avatar: avatar, showAvatar: showAvatars, featuredImage: featuredImage)
|
cell.cellData = TimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, avatar: avatar, showAvatar: showAvatars, featuredImage: featuredImage)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func avatarFor(_ article: Article) -> NSImage? {
|
|
||||||
if !showAvatars {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if let authors = article.authors {
|
|
||||||
for author in authors {
|
|
||||||
if let image = avatarForAuthor(author) {
|
|
||||||
return image
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
guard let feed = article.feed else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if let feedIcon = appDelegate.feedIconDownloader.icon(for: feed) {
|
|
||||||
return feedIcon
|
|
||||||
}
|
|
||||||
|
|
||||||
if let favicon = appDelegate.faviconDownloader.faviconAsAvatar(for: feed) {
|
|
||||||
return favicon
|
|
||||||
}
|
|
||||||
|
|
||||||
return FaviconGenerator.favicon(feed)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func avatarForAuthor(_ author: Author) -> NSImage? {
|
|
||||||
return appDelegate.authorAvatarDownloader.image(for: author)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func featuredImageFor(_ article: Article) -> NSImage? {
|
private func featuredImageFor(_ article: Article) -> NSImage? {
|
||||||
// At this writing (17 June 2019) we’re not displaying featured images anywhere,
|
// At this writing (17 June 2019) we’re not displaying featured images anywhere,
|
||||||
// so let’s skip downloading them even if we find them.
|
// so let’s skip downloading them even if we find them.
|
||||||
|
|
Loading…
Reference in New Issue