Skip showing favicons in the timeline when they’re too small to look good.

This commit is contained in:
Brent Simmons 2018-02-23 23:31:59 -08:00
parent 9e743d0192
commit 5643a51d16

View File

@ -17,7 +17,13 @@ class TimelineTableCellView: NSTableCellView {
private let unreadIndicatorView = UnreadIndicatorView(frame: NSZeroRect)
private let dateView = TimelineTableCellView.singleLineTextField()
private let feedNameView = TimelineTableCellView.singleLineTextField()
private let avatarImageView = TimelineTableCellView.imageView(with: AppImages.genericFeedImage, scaling: .scaleProportionallyDown)
private lazy var avatarImageView: NSImageView = {
let imageView = TimelineTableCellView.imageView(with: AppImages.genericFeedImage, scaling: .scaleProportionallyDown)
imageView.wantsLayer = true
return imageView
}()
private let starView = TimelineTableCellView.imageView(with: AppImages.timelineStar, scaling: .scaleNone)
private lazy var textFields = {
@ -27,6 +33,7 @@ class TimelineTableCellView: NSTableCellView {
var cellAppearance: TimelineCellAppearance! {
didSet {
updateTextFields()
avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius
needsLayout = true
}
}
@ -297,25 +304,26 @@ private extension TimelineTableCellView {
func updateAvatar() {
if !cellData.showAvatar {
avatarImageView.image = nil
hideView(avatarImageView)
// The avatar should be bigger than a favicon. Theyre too small; they look weird.
guard let image = cellData.avatar, cellData.showAvatar, image.size.height >= 22.0, image.size.width >= 22.0 else {
makeAvatarEmpty()
return
}
showView(avatarImageView)
if let image = cellData.avatar {
if avatarImageView.image !== image {
avatarImageView.image = image
needsLayout = true
}
}
else {
avatarImageView.image = nil
}
avatarImageView.wantsLayer = true
avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius
func makeAvatarEmpty() {
if avatarImageView.image != nil {
avatarImageView.image = nil
needsLayout = true
}
hideView(avatarImageView)
}
func hideView(_ view: NSView) {