mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-11 01:04:05 +01:00
Refresh feeds and sidebar when downloaded articles update all their unread counts. Issue #1430
This commit is contained in:
parent
6f2e6a7d9a
commit
e303d64c1d
@ -26,6 +26,7 @@ public extension Notification.Name {
|
|||||||
static let AccountRefreshDidBegin = Notification.Name(rawValue: "AccountRefreshDidBegin")
|
static let AccountRefreshDidBegin = Notification.Name(rawValue: "AccountRefreshDidBegin")
|
||||||
static let AccountRefreshDidFinish = Notification.Name(rawValue: "AccountRefreshDidFinish")
|
static let AccountRefreshDidFinish = Notification.Name(rawValue: "AccountRefreshDidFinish")
|
||||||
static let AccountRefreshProgressDidChange = Notification.Name(rawValue: "AccountRefreshProgressDidChange")
|
static let AccountRefreshProgressDidChange = Notification.Name(rawValue: "AccountRefreshProgressDidChange")
|
||||||
|
static let DownloadArticlesDidUpdateUnreadCounts = Notification.Name(rawValue: "DownloadArticlesDidUpdateUnreadCounts")
|
||||||
static let AccountDidDownloadArticles = Notification.Name(rawValue: "AccountDidDownloadArticles")
|
static let AccountDidDownloadArticles = Notification.Name(rawValue: "AccountDidDownloadArticles")
|
||||||
static let AccountStateDidChange = Notification.Name(rawValue: "AccountStateDidChange")
|
static let AccountStateDidChange = Notification.Name(rawValue: "AccountStateDidChange")
|
||||||
static let StatusesDidChange = Notification.Name(rawValue: "StatusesDidChange")
|
static let StatusesDidChange = Notification.Name(rawValue: "StatusesDidChange")
|
||||||
@ -601,7 +602,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||||||
structureDidChange()
|
structureDidChange()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateUnreadCounts(for webFeeds: Set<WebFeed>) {
|
public func updateUnreadCounts(for webFeeds: Set<WebFeed>, completion: (() -> Void)? = nil) {
|
||||||
if webFeeds.isEmpty {
|
if webFeeds.isEmpty {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -612,6 +613,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||||||
webFeed.unreadCount = unreadCount
|
webFeed.unreadCount = unreadCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
completion?()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,7 +724,9 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
|
|||||||
self.existingWebFeed(withWebFeedID: key)
|
self.existingWebFeed(withWebFeedID: key)
|
||||||
})
|
})
|
||||||
if let newArticles = newArticles, !newArticles.isEmpty {
|
if let newArticles = newArticles, !newArticles.isEmpty {
|
||||||
self.updateUnreadCounts(for: webFeeds)
|
self.updateUnreadCounts(for: webFeeds) {
|
||||||
|
NotificationCenter.default.post(name: .DownloadArticlesDidUpdateUnreadCounts, object: self, userInfo: nil)
|
||||||
|
}
|
||||||
userInfo[UserInfoKey.newArticles] = newArticles
|
userInfo[UserInfoKey.newArticles] = newArticles
|
||||||
}
|
}
|
||||||
if let updatedArticles = updatedArticles, !updatedArticles.isEmpty {
|
if let updatedArticles = updatedArticles, !updatedArticles.isEmpty {
|
||||||
|
@ -65,6 +65,7 @@ protocol SidebarDelegate: class {
|
|||||||
NotificationCenter.default.addObserver(self, selector: #selector(webFeedSettingDidChange(_:)), name: .WebFeedSettingDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(webFeedSettingDidChange(_:)), name: .WebFeedSettingDidChange, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(userDidRequestSidebarSelection(_:)), name: .UserDidRequestSidebarSelection, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(userDidRequestSidebarSelection(_:)), name: .UserDidRequestSidebarSelection, object: nil)
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(downloadArticlesDidUpdateUnreadCounts(_:)), name: .DownloadArticlesDidUpdateUnreadCounts, object: nil)
|
||||||
|
|
||||||
outlineView.reloadData()
|
outlineView.reloadData()
|
||||||
|
|
||||||
@ -149,6 +150,10 @@ protocol SidebarDelegate: class {
|
|||||||
revealAndSelectRepresentedObject(feed as AnyObject)
|
revealAndSelectRepresentedObject(feed as AnyObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func downloadArticlesDidUpdateUnreadCounts(_ note: Notification) {
|
||||||
|
rebuildTreeAndRestoreSelection()
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Actions
|
// MARK: - Actions
|
||||||
|
|
||||||
@IBAction func delete(_ sender: AnyObject?) {
|
@IBAction func delete(_ sender: AnyObject?) {
|
||||||
|
@ -301,6 +301,7 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
NotificationCenter.default.addObserver(self, selector: #selector(userDidDeleteAccount(_:)), name: .UserDidDeleteAccount, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(userDidDeleteAccount(_:)), name: .UserDidDeleteAccount, object: nil)
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
|
||||||
|
NotificationCenter.default.addObserver(self, selector: #selector(downloadArticlesDidUpdateUnreadCounts(_:)), name: .DownloadArticlesDidUpdateUnreadCounts, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(accountDidDownloadArticles(_:)), name: .AccountDidDownloadArticles, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(accountDidDownloadArticles(_:)), name: .AccountDidDownloadArticles, object: nil)
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -522,6 +523,10 @@ class SceneCoordinator: NSObject, UndoableCommandRunner, UnreadCountProvider {
|
|||||||
self.groupByFeed = AppDefaults.timelineGroupByFeed
|
self.groupByFeed = AppDefaults.timelineGroupByFeed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func downloadArticlesDidUpdateUnreadCounts(_ note: Notification) {
|
||||||
|
rebuildBackingStores()
|
||||||
|
}
|
||||||
|
|
||||||
@objc func accountDidDownloadArticles(_ note: Notification) {
|
@objc func accountDidDownloadArticles(_ note: Notification) {
|
||||||
guard let feeds = note.userInfo?[Account.UserInfoKey.webFeeds] as? Set<WebFeed> else {
|
guard let feeds = note.userInfo?[Account.UserInfoKey.webFeeds] as? Set<WebFeed> else {
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user