diff --git a/Evergreen/AppDelegate.swift b/Evergreen/AppDelegate.swift index 412a177fb..3a9dbbeb1 100644 --- a/Evergreen/AppDelegate.swift +++ b/Evergreen/AppDelegate.swift @@ -86,11 +86,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, addFolderWindowController!.runSheetOnWindow(window) } - func markOlderArticlesAsRead(with window: NSWindow) { - - panicButtonWindowController = PanicButtonWindowController() - panicButtonWindowController!.runSheetOnWindow(window) - } +// func markOlderArticlesAsRead(with window: NSWindow) { +// +// panicButtonWindowController = PanicButtonWindowController() +// panicButtonWindowController!.runSheetOnWindow(window) +// } func markEverywhereAsRead(with window: NSWindow) { @@ -431,11 +431,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, Browser.open("https://ranchero.com/evergreen/help/1.0/", inBackground: false) } - @IBAction func markOlderArticlesAsRead(_ sender: Any?) { - - createAndShowMainWindow() - markOlderArticlesAsRead(with: mainWindowController!.window!) - } +// @IBAction func markOlderArticlesAsRead(_ sender: Any?) { +// +// createAndShowMainWindow() +// markOlderArticlesAsRead(with: mainWindowController!.window!) +// } @IBAction func markEverywhereAsRead(_ sender: Any?) { diff --git a/Evergreen/MainWindow/MainWindowController.swift b/Evergreen/MainWindow/MainWindowController.swift index f77b8427a..def09d421 100644 --- a/Evergreen/MainWindow/MainWindowController.swift +++ b/Evergreen/MainWindow/MainWindowController.swift @@ -239,7 +239,8 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { @IBAction func markOlderArticlesAsRead(_ sender: Any?) { - appDelegate.markOlderArticlesAsRead(with: window!) + timelineViewController?.markOlderArticlesAsRead(sender) +// appDelegate.markOlderArticlesAsRead(with: window!) } @IBAction func markEverywhereAsRead(_ sender: Any?) { diff --git a/Evergreen/MainWindow/Timeline/TimelineViewController.swift b/Evergreen/MainWindow/Timeline/TimelineViewController.swift index 5676c22a5..5abf6c1b6 100644 --- a/Evergreen/MainWindow/Timeline/TimelineViewController.swift +++ b/Evergreen/MainWindow/Timeline/TimelineViewController.swift @@ -179,6 +179,34 @@ class TimelineViewController: NSViewController, UndoableCommandRunner { } runCommand(markUnreadCommand) } + + @IBAction func markOlderArticlesAsRead(_ sender: Any?) { + + // Mark articles the same age or older than the selected article(s) as read. + + var cutoffDate: Date? = nil + for article in selectedArticles { + if cutoffDate == nil { + cutoffDate = article.logicalDatePublished + } + else if cutoffDate! < article.logicalDatePublished { + cutoffDate = article.logicalDatePublished + } + } + if cutoffDate == nil { + return + } + + let articlesToMark = articles.filter { $0.logicalDatePublished <= cutoffDate! } + if articlesToMark.isEmpty { + return + } + + guard let undoManager = undoManager, let markReadCommand = MarkReadOrUnreadCommand(initialArticles: articlesToMark, markingRead: true, undoManager: undoManager) else { + return + } + runCommand(markReadCommand) + } // MARK: - Navigation