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 feedsPath: ODBPath
|
||||||
private let feedsTable: ODBTable
|
private let feedsTable: ODBTable
|
||||||
|
|
||||||
|
private var unreadCounts = [String: Int]() // [feedID: Int]
|
||||||
private let opmlFilePath: String
|
private let opmlFilePath: String
|
||||||
|
|
||||||
private struct SettingsKey {
|
private struct SettingsKey {
|
||||||
|
@ -447,6 +448,14 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
||||||
return opml
|
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
|
// MARK: - Debug
|
||||||
|
|
||||||
public func debugDropConditionalGetInfo() {
|
public func debugDropConditionalGetInfo() {
|
||||||
|
|
|
@ -110,11 +110,16 @@ public final class Feed: DisplayNameProvider, UnreadCountProvider, Hashable {
|
||||||
|
|
||||||
// MARK: - UnreadCountProvider
|
// MARK: - UnreadCountProvider
|
||||||
|
|
||||||
public var unreadCount = 0 {
|
public var unreadCount: Int {
|
||||||
didSet {
|
get {
|
||||||
if unreadCount != oldValue {
|
return account?.unreadCount(for: self) ?? 0
|
||||||
postUnreadCountDidChangeNotification()
|
|
||||||
}
|
}
|
||||||
|
set {
|
||||||
|
if unreadCount == newValue {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
account?.setUnreadCount(newValue, for: self)
|
||||||
|
postUnreadCountDidChangeNotification()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue