Use an image for feeds that don’t have favicons. Currently using the image at /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns — but this might change.

This commit is contained in:
Brent Simmons 2017-12-28 18:11:12 -08:00
parent ab80e91ea7
commit 953a97afd7
3 changed files with 14 additions and 2 deletions

View File

@ -27,6 +27,12 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
var feedIconDownloader: FeedIconDownloader! var feedIconDownloader: FeedIconDownloader!
var appName: String! var appName: String!
lazy var genericFeedImage: NSImage? = {
let path = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/BookmarkIcon.icns"
let image = NSImage(contentsOfFile: path)
return image
}()
var unreadCount = 0 { var unreadCount = 0 {
didSet { didSet {
if unreadCount != oldValue { if unreadCount != oldValue {

View File

@ -111,7 +111,10 @@ extension FeedListViewController: NSOutlineViewDelegate {
return NSImage(named: NSImage.Name.folder) return NSImage(named: NSImage.Name.folder)
} }
else if let feed = node.representedObject as? FeedListFeed { else if let feed = node.representedObject as? FeedListFeed {
return appDelegate.faviconDownloader.favicon(withHomePageURL: feed.homePageURL) if let image = appDelegate.faviconDownloader.favicon(withHomePageURL: feed.homePageURL) {
return image
}
return appDelegate.genericFeedImage
} }
return nil return nil
} }

View File

@ -522,7 +522,10 @@ private extension SidebarViewController {
extension Feed: SmallIconProvider { extension Feed: SmallIconProvider {
var smallIcon: NSImage? { var smallIcon: NSImage? {
return appDelegate.faviconDownloader.favicon(for: self) if let image = appDelegate.faviconDownloader.favicon(for: self) {
return image
}
return appDelegate.genericFeedImage
} }
} }