From ea55aa5befebe751861d24ba2bb23a4fd2644a4a Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 24 Aug 2019 15:01:28 -0500 Subject: [PATCH] Leverage new avatarImage function from ArticleUtilities to reduce code duplication between macOS and iOS --- .../Timeline/TimelineViewController.swift | 34 +------------------ 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index 913d7c0b2..95bacbcad 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -768,44 +768,12 @@ extension TimelineViewController: NSTableViewDelegate { private func configureTimelineCell(_ cell: TimelineTableCellView, article: Article) { cell.objectValue = article - let avatar = avatarFor(article) + let avatar = article.avatarImage() let featuredImage = featuredImageFor(article) 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? { // At this writing (17 June 2019) we’re not displaying featured images anywhere, // so let’s skip downloading them even if we find them.