Make the All Unread feed eligible for the Clean Up command. Issue #2417

This commit is contained in:
Maurice Parker 2020-09-13 16:35:51 -05:00
parent 2879baf7ed
commit 3fed4774e3
1 changed files with 10 additions and 1 deletions

View File

@ -44,11 +44,20 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
}
var isCleanUpAvailable: Bool {
guard isReadFiltered ?? false else { return false }
let isEligibleForCleanUp: Bool?
if representedObjects?.count == 1, let timelineFeed = representedObjects?.first as? Feed, timelineFeed.defaultReadFilterType == .alwaysRead {
isEligibleForCleanUp = true
} else {
isEligibleForCleanUp = isReadFiltered
}
guard isEligibleForCleanUp ?? false else { return false }
let readSelectedCount = selectedArticles.filter({ $0.status.read }).count
let readArticleCount = articles.count - unreadCount
let availableToCleanCount = readArticleCount - readSelectedCount
return availableToCleanCount > 0
}