diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift index 228e6cff4..cfe2f33ab 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift @@ -19,9 +19,7 @@ struct TimelineCellData { let text: String let attributedTitle: NSAttributedString //title + text let dateString: String - let attributedDateString: NSAttributedString let feedName: String - let attributedFeedName: NSAttributedString let showFeedName: Bool let avatar: NSImage? // feed icon, user avatar, or favicon let showAvatar: Bool // Make space even when avatar is nil @@ -44,13 +42,6 @@ struct TimelineCellData { } self.dateString = timelineDateString(article.logicalDatePublished) - if let s = attributedDateCache[self.dateString] { - self.attributedDateString = s - } - else { - self.attributedDateString = NSAttributedString(string: self.dateString, attributes: [NSAttributedStringKey.foregroundColor: appearance.dateColor, NSAttributedStringKey.font: appearance.dateFont]) - attributedDateCache[self.dateString] = self.attributedDateString - } if let feedName = feedName { self.feedName = timelineTruncatedFeedName(feedName) @@ -58,13 +49,6 @@ struct TimelineCellData { else { self.feedName = "" } - if let s = attributedFeedNameCache[self.feedName] { - self.attributedFeedName = s - } - else { - self.attributedFeedName = NSAttributedString(string: self.feedName, attributes: [NSAttributedStringKey.foregroundColor: appearance.feedNameColor, NSAttributedStringKey.font: appearance.feedNameFont]) - attributedFeedNameCache[self.feedName] = self.attributedFeedName - } self.showFeedName = showFeedName @@ -82,9 +66,7 @@ struct TimelineCellData { self.attributedTitle = NSAttributedString(string: "") self.text = "" self.dateString = "" - self.attributedDateString = NSAttributedString(string: "") self.feedName = "" - self.attributedFeedName = NSAttributedString(string: "") self.showFeedName = false self.showAvatar = false self.avatar = nil diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift index a1a4f78b7..a96c72d11 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift @@ -87,7 +87,7 @@ private extension TimelineCellLayout { static func rectForDate(_ textBoxRect: NSRect, _ titleRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { - return rectOfLineBelow(textBoxRect, titleRect, appearance.titleBottomMargin, cellData.attributedDateString) + return rectOfLineBelow(textBoxRect, titleRect, appearance.titleBottomMargin, cellData.dateString, appearance.dateFont) } static func rectForFeedName(_ textBoxRect: NSRect, _ dateRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect { @@ -96,13 +96,12 @@ private extension TimelineCellLayout { return NSZeroRect } - return rectOfLineBelow(textBoxRect, dateRect, appearance.titleBottomMargin, cellData.attributedFeedName) + return rectOfLineBelow(textBoxRect, dateRect, appearance.titleBottomMargin, cellData.feedName, appearance.feedNameFont) } - static func rectOfLineBelow(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ topMargin: CGFloat, _ attributedString: NSAttributedString) -> NSRect { + static func rectOfLineBelow(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ topMargin: CGFloat, _ value: String, _ font: NSFont) -> NSRect { - let font = attributedString.attribute(NSAttributedStringKey.font, at: 0, effectiveRange: nil) as! NSFont - let textFieldSize = SingleLineTextFieldSizer.size(for: attributedString.string, font: font) + let textFieldSize = SingleLineTextFieldSizer.size(for: value, font: font) var r = NSZeroRect r.size = textFieldSize r.origin.y = NSMaxY(rectAbove) + topMargin diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift index d73cf0898..5a24be79f 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -236,7 +236,7 @@ private extension TimelineTableCellView { func updateDateView() { - dateView.stringValue = cellData.attributedDateString.string + dateView.stringValue = cellData.dateString needsLayout = true } @@ -246,7 +246,7 @@ private extension TimelineTableCellView { if feedNameView.isHidden { feedNameView.isHidden = false } - feedNameView.stringValue = cellData.attributedFeedName.string + feedNameView.stringValue = cellData.feedName } else { if !feedNameView.isHidden {