mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-24 08:41:31 +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) {
|
@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
|
return
|
||||||
}
|
}
|
||||||
let articlesToReload = articles.filter { (article) -> Bool in
|
|
||||||
guard let authors = article.authors else {
|
var articlesToReload = [Article]()
|
||||||
return false
|
tableView.enumerateAvailableRowViews { (rowView, row) in
|
||||||
|
guard let article = articles.articleAtRow(row), let authors = article.authors, !authors.isEmpty else {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
for oneAuthor in authors {
|
for author in authors {
|
||||||
if oneAuthor.avatarURL == avatarURL {
|
if author.avatarURL == avatarURL {
|
||||||
return true
|
articlesToReload.append(article)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
reloadCellsForArticles(articlesToReload)
|
reloadCellsForArticles(articlesToReload)
|
||||||
}
|
}
|
||||||
@ -373,6 +374,9 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
|||||||
|
|
||||||
private func reloadCellsForArticleIDs(_ articleIDs: Set<String>) {
|
private func reloadCellsForArticleIDs(_ articleIDs: Set<String>) {
|
||||||
|
|
||||||
|
if articleIDs.isEmpty {
|
||||||
|
return
|
||||||
|
}
|
||||||
let indexes = articles.indexesForArticleIDs(articleIDs)
|
let indexes = articles.indexesForArticleIDs(articleIDs)
|
||||||
tableView.reloadData(forRowIndexes: indexes, columnIndexes: NSIndexSet(index: 0) as IndexSet)
|
tableView.reloadData(forRowIndexes: indexes, columnIndexes: NSIndexSet(index: 0) as IndexSet)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user