mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Persist the Feeds Read filter across application launches. Issue #1349
This commit is contained in:
@@ -1098,6 +1098,7 @@ private extension Account {
|
||||
self.fetchingAllUnreadCounts = false
|
||||
self.updateUnreadCount()
|
||||
self.isUnreadCountsInitialized = true
|
||||
self.postUnreadCountDidInitializeNotification()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1111,9 +1112,11 @@ private extension Account {
|
||||
feed.unreadCount = 0
|
||||
}
|
||||
}
|
||||
|
||||
self.fetchingAllUnreadCounts = false
|
||||
self.updateUnreadCount()
|
||||
self.isUnreadCountsInitialized = true
|
||||
self.postUnreadCountDidInitializeNotification()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ public final class AccountManager: UnreadCountProvider {
|
||||
|
||||
readAccountsFromDisk()
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidInitialize(_:)), name: .UnreadCountDidInitialize, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(unreadCountDidChange(_:)), name: .UnreadCountDidChange, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(accountStateDidChange(_:)), name: .AccountStateDidChange, object: nil)
|
||||
|
||||
@@ -269,6 +270,15 @@ public final class AccountManager: UnreadCountProvider {
|
||||
|
||||
// MARK: - Notifications
|
||||
|
||||
@objc func unreadCountDidInitialize(_ notification: Notification) {
|
||||
guard let _ = notification.object as? Account else {
|
||||
return
|
||||
}
|
||||
if isUnreadCountsInitialized {
|
||||
postUnreadCountDidInitializeNotification()
|
||||
}
|
||||
}
|
||||
|
||||
@objc dynamic func unreadCountDidChange(_ notification: Notification) {
|
||||
guard let _ = notification.object as? Account else {
|
||||
return
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
public extension Notification.Name {
|
||||
|
||||
static let UnreadCountDidInitialize = Notification.Name("UnreadCountDidInitialize")
|
||||
static let UnreadCountDidChange = Notification.Name(rawValue: "UnreadCountDidChange")
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@ public protocol UnreadCountProvider {
|
||||
|
||||
public extension UnreadCountProvider {
|
||||
|
||||
func postUnreadCountDidInitializeNotification() {
|
||||
NotificationCenter.default.post(name: .UnreadCountDidInitialize, object: self, userInfo: nil)
|
||||
}
|
||||
|
||||
func postUnreadCountDidChangeNotification() {
|
||||
NotificationCenter.default.post(name: .UnreadCountDidChange, object: self, userInfo: nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user