From 2dbb0a4988b30dffc3a902b1a9f8e22b63b201c5 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 25 Dec 2017 12:21:44 -0800 Subject: [PATCH] Validate the Mark Older Articles as Read command. --- Evergreen/MainWindow/MainWindowController.swift | 13 +++++++++++-- .../Timeline/TimelineViewController.swift | 9 +++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Evergreen/MainWindow/MainWindowController.swift b/Evergreen/MainWindow/MainWindowController.swift index 5c7ed4551..763487533 100644 --- a/Evergreen/MainWindow/MainWindowController.swift +++ b/Evergreen/MainWindow/MainWindowController.swift @@ -127,6 +127,10 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { return canMarkRead() } + if item.action == #selector(markOlderArticlesAsRead(_:)) { + return canMarkOlderArticlesAsRead() + } + return true } @@ -239,7 +243,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { @IBAction func markOlderArticlesAsRead(_ sender: Any?) { - timelineViewController?.markOlderArticlesAsRead(sender) + timelineViewController?.markOlderArticlesAsRead() } @IBAction func navigateToTimeline(_ sender: Any?) { @@ -339,7 +343,12 @@ private extension MainWindowController { return timelineViewController?.canMarkSelectedArticlesAsRead() ?? false } - + + func canMarkOlderArticlesAsRead() -> Bool { + + return timelineViewController?.canMarkOlderArticlesAsRead() ?? false + } + func updateWindowTitle() { if unreadCount < 1 { diff --git a/Evergreen/MainWindow/Timeline/TimelineViewController.swift b/Evergreen/MainWindow/Timeline/TimelineViewController.swift index 5abf6c1b6..f514a27e7 100644 --- a/Evergreen/MainWindow/Timeline/TimelineViewController.swift +++ b/Evergreen/MainWindow/Timeline/TimelineViewController.swift @@ -180,7 +180,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner { runCommand(markUnreadCommand) } - @IBAction func markOlderArticlesAsRead(_ sender: Any?) { + func markOlderArticlesAsRead() { // Mark articles the same age or older than the selected article(s) as read. @@ -207,7 +207,12 @@ class TimelineViewController: NSViewController, UndoableCommandRunner { } runCommand(markReadCommand) } - + + func canMarkOlderArticlesAsRead() -> Bool { + + return !selectedArticles.isEmpty + } + // MARK: - Navigation func goToNextUnread() {