diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index a433f80ea..8a652a655 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -39,7 +39,9 @@ public final class Account: DisplayNameProvider, Container, Hashable { public struct UserInfoKey { public static let newArticles = "newArticles" // AccountDidDownloadArticles public static let updatedArticles = "updatedArticles" // AccountDidDownloadArticles - public static let statuses = "statuses" // ArticleStatusesDidChange + public static let statuses = "statuses" // StatusesDidChange + public static let articles = "articles" // StatusesDidChange + public static let feeds = "feeds" // StatusesDidChange } public let accountID: String @@ -157,7 +159,12 @@ 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) { - NotificationCenter.default.post(name: .StatusesDidChange, object: self, userInfo: [UserInfoKey.statuses: updatedStatuses]) + + 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]) } } diff --git a/Frameworks/Account/DataExtensions.swift b/Frameworks/Account/DataExtensions.swift index 5325b3c88..7a4234e29 100644 --- a/Frameworks/Account/DataExtensions.swift +++ b/Frameworks/Account/DataExtensions.swift @@ -29,9 +29,15 @@ public extension Feed { public extension Article { - var account: Account? { + public var account: Account? { get { return AccountManager.shared.existingAccount(with: accountID) } } + + public var feed: Feed? { + get { + return account?.existingFeed(with: feedID) + } + } }