changed to queue a reload of all visible cells when a favicon comes in

This commit is contained in:
Maurice Parker 2019-09-06 17:22:12 -05:00
parent a4b01fda35
commit 7d8a0234b6
1 changed files with 7 additions and 12 deletions

View File

@ -354,17 +354,8 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
} }
@objc func faviconDidBecomeAvailable(_ note: Notification) { @objc func faviconDidBecomeAvailable(_ note: Notification) {
guard coordinator.showAvatars, let faviconURL = note.userInfo?["faviconURL"] as? String else { if coordinator.showAvatars {
return queueReloadAvailableCells()
}
tableView.indexPathsForVisibleRows?.forEach { indexPath in
guard let article = coordinator.articles.articleAtRow(indexPath.row), let articleFaviconURL = article.feed?.faviconURL else {
return
}
if faviconURL == articleFaviconURL, let cell = tableView.cellForRow(at: indexPath) as? MasterTimelineTableViewCell, let image = avatarFor(article) {
cell.setAvatarImage(image)
return
}
} }
} }
@ -386,7 +377,11 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
// MARK: Reloading // MARK: Reloading
private func reloadAllVisibleCells() { func queueReloadAvailableCells() {
CoalescingQueue.standard.add(self, #selector(reloadAllVisibleCells))
}
@objc private func reloadAllVisibleCells() {
let visibleArticles = tableView.indexPathsForVisibleRows!.map { return coordinator.articles[$0.row] } let visibleArticles = tableView.indexPathsForVisibleRows!.map { return coordinator.articles[$0.row] }
reloadCells(visibleArticles) reloadCells(visibleArticles)
} }