Make clean up availability take read count into consideration. Issue #2352

This commit is contained in:
Maurice Parker 2020-08-18 15:04:30 -05:00
parent 348e8734e7
commit b0de353d02
3 changed files with 15 additions and 3 deletions

View File

@ -918,9 +918,7 @@ private extension MainWindowController {
} }
func validateCleanUp(_ item: NSValidatedUserInterfaceItem) -> Bool { func validateCleanUp(_ item: NSValidatedUserInterfaceItem) -> Bool {
let isSidebarFiltered = sidebarViewController?.isReadFiltered ?? false return timelineContainerViewController?.isCleanUpAvailable ?? false
let isTimelineFiltered = timelineContainerViewController?.isReadFiltered ?? false
return isSidebarFiltered || isTimelineFiltered
} }
func validateToggleReadFeeds(_ item: NSValidatedUserInterfaceItem) -> Bool { func validateToggleReadFeeds(_ item: NSValidatedUserInterfaceItem) -> Bool {

View File

@ -45,6 +45,11 @@ final class TimelineContainerViewController: NSViewController {
return regularTimelineViewController.isReadFiltered return regularTimelineViewController.isReadFiltered
} }
var isCleanUpAvailable: Bool {
guard let currentTimelineViewController = currentTimelineViewController, mode(for: currentTimelineViewController) == .regular else { return false }
return regularTimelineViewController.isCleanUpAvailable
}
lazy var regularTimelineViewController = { lazy var regularTimelineViewController = {
return TimelineViewController(delegate: self) return TimelineViewController(delegate: self)
}() }()

View File

@ -43,6 +43,15 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
} }
} }
var isCleanUpAvailable: Bool {
guard isReadFiltered ?? false else { return false }
let readSelectedCount = selectedArticles.filter({ $0.status.read }).count
let readArticleCount = articles.count - unreadCount
let availableToCleanCount = readArticleCount - readSelectedCount
return availableToCleanCount > 0
}
var representedObjects: [AnyObject]? { var representedObjects: [AnyObject]? {
didSet { didSet {
if !representedObjectArraysAreEqual(oldValue, representedObjects) { if !representedObjectArraysAreEqual(oldValue, representedObjects) {