mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-24 00:30:51 +01:00
Make updating the timeline cells more efficient after downloading an avatar.
This commit is contained in:
parent
b83e0eeb67
commit
f9b4e192e0
@ -327,19 +327,20 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||
|
||||
@objc func avatarDidBecomeAvailable(_ note: Notification) {
|
||||
|
||||
guard let avatarURL = note.userInfo?[UserInfoKey.url] as? String else {
|
||||
guard showAvatars, let avatarURL = note.userInfo?[UserInfoKey.url] as? String else {
|
||||
return
|
||||
}
|
||||
let articlesToReload = articles.filter { (article) -> Bool in
|
||||
guard let authors = article.authors else {
|
||||
return false
|
||||
|
||||
var articlesToReload = [Article]()
|
||||
tableView.enumerateAvailableRowViews { (rowView, row) in
|
||||
guard let article = articles.articleAtRow(row), let authors = article.authors, !authors.isEmpty else {
|
||||
return
|
||||
}
|
||||
for oneAuthor in authors {
|
||||
if oneAuthor.avatarURL == avatarURL {
|
||||
return true
|
||||
for author in authors {
|
||||
if author.avatarURL == avatarURL {
|
||||
articlesToReload.append(article)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
reloadCellsForArticles(articlesToReload)
|
||||
}
|
||||
@ -373,6 +374,9 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||
|
||||
private func reloadCellsForArticleIDs(_ articleIDs: Set<String>) {
|
||||
|
||||
if articleIDs.isEmpty {
|
||||
return
|
||||
}
|
||||
let indexes = articles.indexesForArticleIDs(articleIDs)
|
||||
tableView.reloadData(forRowIndexes: indexes, columnIndexes: NSIndexSet(index: 0) as IndexSet)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user