mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Create and use IconImageCache. It centralizes and de-dupes logic for getting feed/article images, and it caches the results, which helps performance.
This commit is contained in:
@@ -763,7 +763,7 @@ private extension SidebarViewController {
|
||||
}
|
||||
|
||||
func imageFor(_ node: Node) -> IconImage? {
|
||||
if let feed = node.representedObject as? WebFeed, let feedIcon = appDelegate.webFeedIconDownloader.icon(for: feed) {
|
||||
if let feed = node.representedObject as? WebFeed, let feedIcon = IconImageCache.shared.imageForFeed(feed) {
|
||||
return feedIcon
|
||||
}
|
||||
if let smallIconProvider = node.representedObject as? SmallIconProvider {
|
||||
|
||||
@@ -886,28 +886,7 @@ extension TimelineViewController: NSTableViewDelegate {
|
||||
if !showIcons {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let authors = article.authors {
|
||||
for author in authors {
|
||||
if let image = avatarForAuthor(author) {
|
||||
return image
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guard let feed = article.webFeed else {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let feedIcon = appDelegate.webFeedIconDownloader.icon(for: feed) {
|
||||
return feedIcon
|
||||
}
|
||||
|
||||
if let favicon = appDelegate.faviconDownloader.faviconAsIcon(for: feed) {
|
||||
return favicon
|
||||
}
|
||||
|
||||
return FaviconGenerator.favicon(feed)
|
||||
return IconImageCache.shared.imageForArticle(article)
|
||||
}
|
||||
|
||||
private func avatarForAuthor(_ author: Author) -> IconImage? {
|
||||
|
||||
Reference in New Issue
Block a user