Store feed.unreadCount with the Account rather than the feed. This is part of making it so that feeds no longer have to be uniqued.
This commit is contained in:
parent
28d084e246
commit
47cf018143
|
@ -63,6 +63,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
private let feedsPath: ODBPath
|
||||
private let feedsTable: ODBTable
|
||||
|
||||
private var unreadCounts = [String: Int]() // [feedID: Int]
|
||||
private let opmlFilePath: String
|
||||
|
||||
private struct SettingsKey {
|
||||
|
@ -447,6 +448,14 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||
return opml
|
||||
}
|
||||
|
||||
public func unreadCount(for feed: Feed) -> Int {
|
||||
return unreadCounts[feed.feedID] ?? 0
|
||||
}
|
||||
|
||||
public func setUnreadCount(_ unreadCount: Int, for feed: Feed) {
|
||||
unreadCounts[feed.feedID] = unreadCount
|
||||
}
|
||||
|
||||
// MARK: - Debug
|
||||
|
||||
public func debugDropConditionalGetInfo() {
|
||||
|
|
|
@ -110,11 +110,16 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
|
|||
|
||||
// MARK: - UnreadCountProvider
|
||||
|
||||
public var unreadCount = 0 {
|
||||
didSet {
|
||||
if unreadCount != oldValue {
|
||||
postUnreadCountDidChangeNotification()
|
||||
public var unreadCount: Int {
|
||||
get {
|
||||
return account?.unreadCount(for: self) ?? 0
|
||||
}
|
||||
set {
|
||||
if unreadCount == newValue {
|
||||
return
|
||||
}
|
||||
account?.setUnreadCount(newValue, for: self)
|
||||
postUnreadCountDidChangeNotification()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue