Update unread counts for feeds when statuses change.

This commit is contained in:
Brent Simmons 2017-10-09 21:54:08 -07:00
parent 106cedb638
commit f5a5bf91b2
3 changed files with 19 additions and 14 deletions

View File

@ -225,10 +225,10 @@ class TimelineViewController: NSViewController, NSTableViewDelegate, NSTableView
@objc func statusesDidChange(_ note: Notification) {
guard let statuses = note.userInfo?[Account.UserInfoKey.statuses] as? Set<ArticleStatus> else {
guard let articles = note.userInfo?[Account.UserInfoKey.articles] as? Set<Article> else {
return
}
reloadCellsForArticleIDs(statuses.articleIDs())
reloadCellsForArticleIDs(articles.articleIDs())
}
func fontSizeInDefaultsDidChange() {

View File

@ -158,14 +158,17 @@ public final class Account: DisplayNameProvider, Container, Hashable {
public func markArticles(_ articles: Set<Article>, 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
}
}

View File

@ -8,15 +8,15 @@
<dateCreated>Tue, 12 Sep 2017 20:15:17 GMT</dateCreated>
<expansionState>0,23,24,27,31,37,45,46,48,63,68</expansionState>
<vertScrollState>0</vertScrollState>
<windowTop>637</windowTop>
<windowLeft>42</windowLeft>
<windowRight>774</windowRight>
<windowBottom>1396</windowBottom>
<windowTop>630</windowTop>
<windowLeft>38</windowLeft>
<windowRight>770</windowRight>
<windowBottom>1389</windowBottom>
</head>
<body>
<outline text="App">
<outline text="Make adding a Folder work — accounts dont show up in Accounts popup"/>
<outline text="Update unread count on marking article status"/>
<outline text="Update unread counts for folders and accounts when statuses change"/>
<outline text="Update Sparkle"/>
<outline text="Use new app icon"/>
<outline text="Set -NSApplicationCrashOnExceptions YES"/>