Add a SmartFeedType to smart feeds so the sidebar can tell them apart.

This commit is contained in:
Brent Simmons 2019-08-13 20:28:28 -07:00
parent 62258683c8
commit cf1b3843ee
3 changed files with 15 additions and 4 deletions

View File

@ -455,7 +455,7 @@ extension MainWindowController: NSSearchFieldDelegate {
return return
} }
lastSentSearchString = searchString lastSentSearchString = searchString
let smartFeed = SmartFeed(delegate: SearchFeedDelegate(searchString: searchString)) let smartFeed = SmartFeed(delegate: SearchFeedDelegate(searchString: searchString), type: .search)
timelineContainerViewController?.setRepresentedObjects([smartFeed], mode: .search) timelineContainerViewController?.setRepresentedObjects([smartFeed], mode: .search)
searchSmartFeed = smartFeed searchSmartFeed = smartFeed
} }

View File

@ -11,12 +11,22 @@ import RSCore
import Articles import Articles
import Account import Account
enum SmartFeedType {
case today
case allUnread
case starred
case search
case custom
}
final class SmartFeed: PseudoFeed { final class SmartFeed: PseudoFeed {
var nameForDisplay: String { var nameForDisplay: String {
return delegate.nameForDisplay return delegate.nameForDisplay
} }
let type: SmartFeedType
var unreadCount = 0 { var unreadCount = 0 {
didSet { didSet {
if unreadCount != oldValue { if unreadCount != oldValue {
@ -34,8 +44,9 @@ final class SmartFeed: PseudoFeed {
private let delegate: SmartFeedDelegate private let delegate: SmartFeedDelegate
private var unreadCounts = [String: Int]() private var unreadCounts = [String: Int]()
init(delegate: SmartFeedDelegate) { init(delegate: SmartFeedDelegate, type: SmartFeedType) {
self.delegate = delegate self.delegate = delegate
self.type = type
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
queueFetchUnreadCounts() // Fetch unread count at startup queueFetchUnreadCounts() // Fetch unread count at startup
} }

View File

@ -15,9 +15,9 @@ final class SmartFeedsController: DisplayNameProvider {
let nameForDisplay = NSLocalizedString("Smart Feeds", comment: "Smart Feeds group title") let nameForDisplay = NSLocalizedString("Smart Feeds", comment: "Smart Feeds group title")
var smartFeeds = [AnyObject]() var smartFeeds = [AnyObject]()
let todayFeed = SmartFeed(delegate: TodayFeedDelegate()) let todayFeed = SmartFeed(delegate: TodayFeedDelegate(), type: .today)
let unreadFeed = UnreadFeed() let unreadFeed = UnreadFeed()
let starredFeed = SmartFeed(delegate: StarredFeedDelegate()) let starredFeed = SmartFeed(delegate: StarredFeedDelegate(), type: .starred)
private init() { private init() {