From f5a5bf91b28720ad9e5b45ac54a5d1e1d8cb9d6e Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 9 Oct 2017 21:54:08 -0700 Subject: [PATCH] Update unread counts for feeds when statuses change. --- .../Timeline/TimelineViewController.swift | 4 ++-- Frameworks/Account/Account.swift | 19 ++++++++++++------- ToDo.opml | 10 +++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Evergreen/MainWindow/Timeline/TimelineViewController.swift b/Evergreen/MainWindow/Timeline/TimelineViewController.swift index 0a112e3cb..f57481a64 100644 --- a/Evergreen/MainWindow/Timeline/TimelineViewController.swift +++ b/Evergreen/MainWindow/Timeline/TimelineViewController.swift @@ -225,10 +225,10 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView @objc func statusesDidChange(_ note: Notification) { - guard let statuses = note.userInfo?[Account.UserInfoKey.statuses] as? Set else { + guard let articles = note.userInfo?[Account.UserInfoKey.articles] as? Set
else { return } - reloadCellsForArticleIDs(statuses.articleIDs()) + reloadCellsForArticleIDs(articles.articleIDs()) } func fontSizeInDefaultsDidChange() { diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 8a652a655..575fa2fb3 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -158,14 +158,17 @@ public final class Account: DisplayNameProvider, Container, Hashable { public func markArticles(_ articles: Set
, statusKey: ArticleStatus.Key, flag: Bool) { - if let updatedStatuses = database.mark(articles, statusKey: statusKey, flag: flag) { - - let updatedArticleIDs = updatedStatuses.articleIDs() - let updatedArticles = Set(articles.filter{ updatedArticleIDs.contains($0.articleID) }) - let updatedFeeds = Set(articles.flatMap{ $0.feed }) - - NotificationCenter.default.post(name: .StatusesDidChange, object: self, userInfo: [UserInfoKey.statuses: updatedStatuses, UserInfoKey.articles: updatedArticles, UserInfoKey.feeds: updatedFeeds]) + guard let updatedStatuses = database.mark(articles, statusKey: statusKey, flag: flag) else { + return } + + let updatedArticleIDs = updatedStatuses.articleIDs() + let updatedArticles = Set(articles.filter{ updatedArticleIDs.contains($0.articleID) }) + let updatedFeeds = Set(articles.flatMap{ $0.feed }) + + updateUnreadCounts(for: updatedFeeds) + + NotificationCenter.default.post(name: .StatusesDidChange, object: self, userInfo: [UserInfoKey.statuses: updatedStatuses, UserInfoKey.articles: updatedArticles, UserInfoKey.feeds: updatedFeeds]) } public func ensureFolder(with name: String) -> Folder? { @@ -251,6 +254,8 @@ public final class Account: DisplayNameProvider, Container, Hashable { feed.unreadCount = unreadCount } } + + self.dirty = true } } diff --git a/ToDo.opml b/ToDo.opml index 031993071..2555b039e 100644 --- a/ToDo.opml +++ b/ToDo.opml @@ -8,15 +8,15 @@ Tue, 12 Sep 2017 20:15:17 GMT 0,23,24,27,31,37,45,46,48,63,68 0 - 637 - 42 - 774 - 1396 + 630 + 38 + 770 + 1389 - +