Implement markOlderArticlesAsRead. Fix #199.

This commit is contained in:
Brent Simmons 2017-12-25 10:40:06 -08:00
parent 6a09a2d6ef
commit c38b46a29e
3 changed files with 40 additions and 11 deletions

View File

@ -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?) {

View File

@ -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?) {

View File

@ -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