From 0336e30b0d8e2dfcbd68e91216a48dc7d1d61396 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 17 Sep 2017 16:30:45 -0700 Subject: [PATCH] Continue to fix build errors. --- Evergreen/Data/ArticleUtilities.swift | 19 ++++++++++++++++--- .../MainWindow/Detail/ArticleRenderer.swift | 3 +-- .../MainWindow/MainWindowController.swift | 4 ++-- .../MainWindow/StatusBar/StatusBarView.swift | 3 +-- .../Timeline/Cell/TimelineCellData.swift | 8 ++++---- .../Timeline/TimelineViewController.swift | 5 +---- Frameworks/Account/Account.swift | 5 +++++ 7 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Evergreen/Data/ArticleUtilities.swift b/Evergreen/Data/ArticleUtilities.swift index 2024cf5fa..5521fd2f6 100644 --- a/Evergreen/Data/ArticleUtilities.swift +++ b/Evergreen/Data/ArticleUtilities.swift @@ -43,8 +43,21 @@ private func accountAndArticlesDictionary(_ articles: Set
) -> [String: extension Article { - func preferredLink() -> String? { - - return url ?? externalURL + var status: ArticleStatus? { + get { + return account?.articleStatus(for: self) + } + } + + var preferredLink: String? { + get { + return url ?? externalURL + } + } + + var body: String? { + get { + return contentHTML ?? contentText ?? summary + } } } diff --git a/Evergreen/MainWindow/Detail/ArticleRenderer.swift b/Evergreen/MainWindow/Detail/ArticleRenderer.swift index 8281c1284..ddae91607 100644 --- a/Evergreen/MainWindow/Detail/ArticleRenderer.swift +++ b/Evergreen/MainWindow/Detail/ArticleRenderer.swift @@ -138,8 +138,7 @@ class ArticleRenderer { private func titleOrTitleLink() -> String { - let link = preferredLink(for: article) - if let link = link { + if let link = article.preferredLink { return linkWithText(title, link) } return title diff --git a/Evergreen/MainWindow/MainWindowController.swift b/Evergreen/MainWindow/MainWindowController.swift index abd6e1759..f0942db8c 100644 --- a/Evergreen/MainWindow/MainWindowController.swift +++ b/Evergreen/MainWindow/MainWindowController.swift @@ -24,7 +24,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { detailSplitViewItem?.minimumThickness = 384 - NotificationCenter.default.addObserver(self, selector: #selector(applicationWillTerminate(_:)), name: .NSApplicationWillTerminate, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(applicationWillTerminate(_:)), name: NSApplication.willTerminateNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(appNavigationKeyPressed(_:)), name: .AppNavigationKeyPressed, object: nil) @@ -174,7 +174,7 @@ private extension MainWindowController { var currentLink: String? { get { if let article = oneSelectedArticle { - return preferredLink(for: article) + return article.preferredLink } return nil } diff --git a/Evergreen/MainWindow/StatusBar/StatusBarView.swift b/Evergreen/MainWindow/StatusBar/StatusBarView.swift index 66dc2a817..61d5e19bc 100644 --- a/Evergreen/MainWindow/StatusBar/StatusBarView.swift +++ b/Evergreen/MainWindow/StatusBar/StatusBarView.swift @@ -91,8 +91,7 @@ private extension StatusBarView { return } - let s = article.preferredLink() - if let s = s { + if let s = article.preferredLink { urlLabel.stringValue = (s as NSString).rs_stringByStrippingHTTPOrHTTPSScheme() } else { diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift index c247aa6bf..eab863415 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineCellData.swift @@ -103,16 +103,16 @@ private func attributedTitleString(_ title: String, _ text: String, _ appearance if !title.isEmpty && !text.isEmpty { - let titleMutable = NSMutableAttributedString(string: title, attributes: [NSForegroundColorAttributeName: appearance.titleColor, NSFontAttributeName: appearance.titleFont]) - let attributedText = NSAttributedString(string: "\n" + text, attributes: [NSForegroundColorAttributeName: appearance.textColor, NSFontAttributeName: appearance.textFont]) + let titleMutable = NSMutableAttributedString(string: title, attributes: [NSAttributedStringKey.foregroundColor: appearance.titleColor, NSAttributedStringKey.font: appearance.titleFont]) + let attributedText = NSAttributedString(string: "\n" + text, attributes: [NSAttributedStringKey.foregroundColor: appearance.textColor, NSAttributedStringKey.font: appearance.textFont]) titleMutable.append(attributedText) return titleMutable } if !title.isEmpty && text.isEmpty { - return NSAttributedString(string: title, attributes: [NSForegroundColorAttributeName: appearance.titleColor, NSFontAttributeName: appearance.titleFont]) + return NSAttributedString(string: title, attributes: [NSAttributedStringKey.foregroundColor: appearance.titleColor, NSAttributedStringKey.font: appearance.titleFont]) } - return NSAttributedString(string: text, attributes: [NSForegroundColorAttributeName: appearance.textColor, NSFontAttributeName: appearance.textFont]) + return NSAttributedString(string: text, attributes: [NSAttributedStringKey.foregroundColor: appearance.textColor, NSAttributedStringKey.font: appearance.textFont]) } diff --git a/Evergreen/MainWindow/Timeline/TimelineViewController.swift b/Evergreen/MainWindow/Timeline/TimelineViewController.swift index eb28dd0a8..026688bd3 100644 --- a/Evergreen/MainWindow/Timeline/TimelineViewController.swift +++ b/Evergreen/MainWindow/Timeline/TimelineViewController.swift @@ -135,10 +135,7 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView @objc func openArticleInBrowser(_ sender: AnyObject) { - guard let article = oneSelectedArticle else { - return - } - if let link = preferredLink(for: article) { + if let link = oneSelectedArticle?.preferredLink { openInBrowser(link) } } diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index d5d2f16ab..98f587993 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -70,6 +70,11 @@ public final class Account: DisplayNameProvider, Hashable { // TODO } + public func articleStatus(for article: Article) -> ArticleStatus? { + + // TODO + } + public func ensureFolder(with name: String) -> Folder? { return nil //TODO