diff --git a/NetNewsWire/MainWindow/MainWindowController.swift b/NetNewsWire/MainWindow/MainWindowController.swift index cf72b11f8..ce535fa26 100644 --- a/NetNewsWire/MainWindow/MainWindowController.swift +++ b/NetNewsWire/MainWindow/MainWindowController.swift @@ -261,7 +261,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { @IBAction func markOlderArticlesAsRead(_ sender: Any?) { - timelineViewController?.markOlderArticlesAsRead() + timelineViewController?.markOlderArticlesRead() } @IBAction func navigateToTimeline(_ sender: Any?) { diff --git a/NetNewsWire/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift b/NetNewsWire/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift index 1dcae135a..d8d9d90af 100644 --- a/NetNewsWire/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift +++ b/NetNewsWire/MainWindow/Timeline/TimelineViewController+ContextualMenus.swift @@ -44,7 +44,15 @@ extension TimelineViewController { guard let articles = articles(from: sender) else { return } - markArticles(articles, read: false) + markOlderArticlesRead(articles) + } + + @objc func markOlderArticlesReadFromContextualMenu(_ sender: Any?) { + + guard let articles = articles(from: sender) else { + return + } + markOlderArticlesRead(articles) } @objc func markArticlesStarredFromContextualMenu(_ sender: Any?) { @@ -134,6 +142,9 @@ private extension TimelineViewController { if articles.anyArticleIsStarred() { menu.addItem(markUnstarredMenuItem(articles)) } + if articles.count > 0 { + menu.addItem(markOlderReadMenuItem(articles)) + } menu.addSeparatorIfNeeded() if articles.count == 1, let link = articles.first!.preferredLink { @@ -195,6 +206,10 @@ private extension TimelineViewController { return menuItem(NSLocalizedString("Mark as Unstarred", comment: "Command"), #selector(markArticlesUnstarredFromContextualMenu(_:)), articles) } + func markOlderReadMenuItem(_ articles: [Article]) -> NSMenuItem { + return menuItem(NSLocalizedString("Mark Older as Read", comment: "Command"), #selector(markOlderArticlesReadFromContextualMenu(_:)), articles) + } + func openInBrowserMenuItem(_ urlString: String) -> NSMenuItem { return menuItem(NSLocalizedString("Open in Browser", comment: "Command"), #selector(openInBrowserFromContextualMenu(_:)), urlString) diff --git a/NetNewsWire/MainWindow/Timeline/TimelineViewController.swift b/NetNewsWire/MainWindow/Timeline/TimelineViewController.swift index 7086d9105..467daf8d6 100644 --- a/NetNewsWire/MainWindow/Timeline/TimelineViewController.swift +++ b/NetNewsWire/MainWindow/Timeline/TimelineViewController.swift @@ -240,9 +240,16 @@ class TimelineViewController: NSViewController, UndoableCommandRunner { return MarkCommandValidationStatus.statusFor(selectedArticles) { $0.anyArticleIsUnread() } } - func markOlderArticlesAsRead() { + func markOlderArticlesRead() { + markOlderArticlesRead(selectedArticles) + } - // Mark articles the same age or older than the selected article(s) as read. + func canMarkOlderArticlesAsRead() -> Bool { + return !selectedArticles.isEmpty + } + + func markOlderArticlesRead(_ selectedArticles: [Article]) { + // Mark articles the same age or older than the selectedArticles(s) as read. var cutoffDate: Date? = nil for article in selectedArticles { @@ -268,11 +275,6 @@ class TimelineViewController: NSViewController, UndoableCommandRunner { runCommand(markReadCommand) } - func canMarkOlderArticlesAsRead() -> Bool { - - return !selectedArticles.isEmpty - } - // MARK: - Navigation func goToNextUnread() {