Remove a no-longer-used Account.update function — we have a new one that’s way faster. Also: assert that we’re in the main thread in that new update function.

This commit is contained in:
Brent Simmons 2019-10-13 19:23:36 -07:00
parent 1d0cacd5fc
commit fcb0f0c439
1 changed files with 1 additions and 19 deletions

View File

@ -580,6 +580,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
func update(feedIDsAndItems: [String: Set<ParsedItem>], defaultRead: Bool, completion: @escaping (() -> Void)) {
assert(Thread.isMainThread)
guard !feedIDsAndItems.isEmpty else {
completion()
return
@ -604,25 +605,6 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
}
func update(_ feed: Feed, parsedItems: Set<ParsedItem>, defaultRead: Bool = false, _ completion: @escaping (() -> Void)) {
let feedIDsAndItems = [feed.feedID: parsedItems]
database.update(feedIDsAndItems: feedIDsAndItems, defaultRead: defaultRead) { (newArticles, updatedArticles) in
var userInfo = [String: Any]()
if let newArticles = newArticles, !newArticles.isEmpty {
self.updateUnreadCounts(for: Set([feed]))
userInfo[UserInfoKey.newArticles] = newArticles
}
if let updatedArticles = updatedArticles, !updatedArticles.isEmpty {
userInfo[UserInfoKey.updatedArticles] = updatedArticles
}
userInfo[UserInfoKey.feeds] = Set([feed])
completion()
NotificationCenter.default.post(name: .AccountDidDownloadArticles, object: self, userInfo: userInfo)
}
}
@discardableResult
func update(_ articles: Set<Article>, statusKey: ArticleStatus.Key, flag: Bool) -> Set<Article>? {
// Returns set of Articles whose statuses did change.