Make reloading the timeline cells even more efficient upon avatar-download.
This commit is contained in:
parent
f9b4e192e0
commit
cfcfe2b4b5
|
@ -331,18 +331,19 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var articlesToReload = [Article]()
|
var indexes = IndexSet()
|
||||||
tableView.enumerateAvailableRowViews { (rowView, row) in
|
tableView.enumerateAvailableRowViews { (rowView, row) in
|
||||||
guard let article = articles.articleAtRow(row), let authors = article.authors, !authors.isEmpty else {
|
guard let article = articles.articleAtRow(row), let authors = article.authors, !authors.isEmpty else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for author in authors {
|
for author in authors {
|
||||||
if author.avatarURL == avatarURL {
|
if author.avatarURL == avatarURL {
|
||||||
articlesToReload.append(article)
|
indexes.insert(row)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reloadCellsForArticles(articlesToReload)
|
reloadCells(for: indexes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fontSizeInDefaultsDidChange() {
|
func fontSizeInDefaultsDidChange() {
|
||||||
|
@ -358,7 +359,7 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Reloading Data
|
// MARK: - Reloading Data
|
||||||
|
|
||||||
private func cellForRowView(_ rowView: NSView) -> NSView? {
|
private func cellForRowView(_ rowView: NSView) -> NSView? {
|
||||||
|
|
||||||
for oneView in rowView.subviews where oneView is TimelineTableCellView {
|
for oneView in rowView.subviews where oneView is TimelineTableCellView {
|
||||||
|
@ -378,6 +379,14 @@ class TimelineViewController: NSViewController, UndoableCommandRunner {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let indexes = articles.indexesForArticleIDs(articleIDs)
|
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)
|
tableView.reloadData(forRowIndexes: indexes, columnIndexes: NSIndexSet(index: 0) as IndexSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue