Update appropriate counts in the sidebar when the timeline’s unread count changes. Fix #829.

This commit is contained in:
Brent Simmons
2019-08-13 21:07:39 -07:00
parent fc0fc2055e
commit 2bbd135c9e
4 changed files with 23 additions and 28 deletions

View File

@@ -11,22 +11,12 @@ import RSCore
import Articles
import Account
enum SmartFeedType {
case today
case allUnread
case starred
case search
case custom
}
final class SmartFeed: PseudoFeed {
var nameForDisplay: String {
return delegate.nameForDisplay
}
let type: SmartFeedType
var unreadCount = 0 {
didSet {
if unreadCount != oldValue {
@@ -44,9 +34,8 @@ final class SmartFeed: PseudoFeed {
private let delegate: SmartFeedDelegate
private var unreadCounts = [String: Int]()
init(delegate: SmartFeedDelegate, type: SmartFeedType) {
init(delegate: SmartFeedDelegate) {
self.delegate = delegate
self.type = type
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
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")
var smartFeeds = [AnyObject]()
let todayFeed = SmartFeed(delegate: TodayFeedDelegate(), type: .today)
let todayFeed = SmartFeed(delegate: TodayFeedDelegate())
let unreadFeed = UnreadFeed()
let starredFeed = SmartFeed(delegate: StarredFeedDelegate(), type: .starred)
let starredFeed = SmartFeed(delegate: StarredFeedDelegate())
private init() {