Make reloading the timeline cells even more efficient upon avatar-download.

This commit is contained in:
Brent Simmons 2018-01-06 11:56:32 -08:00
parent f9b4e192e0
commit cfcfe2b4b5
1 changed files with 13 additions and 4 deletions

View File

@ -331,18 +331,19 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
return
}
var articlesToReload = [Article]()
var indexes = IndexSet()
tableView.enumerateAvailableRowViews { (rowView, row) in
guard let article = articles.articleAtRow(row), let authors = article.authors, !authors.isEmpty else {
return
}
for author in authors {
if author.avatarURL == avatarURL {
articlesToReload.append(article)
indexes.insert(row)
return
}
}
}
reloadCellsForArticles(articlesToReload)
reloadCells(for: indexes)
}
func fontSizeInDefaultsDidChange() {
@ -378,6 +379,14 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
return
}
let indexes = articles.indexesForArticleIDs(articleIDs)
reloadCells(for: indexes)
}
private func reloadCells(for indexes: IndexSet) {
if indexes.isEmpty {
return
}
tableView.reloadData(forRowIndexes: indexes, columnIndexes: NSIndexSet(index: 0) as IndexSet)
}