Change to directly modify the avatar image instead of calling reload on the cells

This commit is contained in:
Maurice Parker 2019-08-26 15:37:15 -05:00
parent 8de9b355c7
commit d7c90106d1
2 changed files with 10 additions and 7 deletions

View File

@ -78,6 +78,10 @@ class MasterTimelineTableViewCell: UITableViewCell {
}
func setAvatarImage(_ image: UIImage) {
avatarImageView.image = image
}
}
// MARK: - Private

View File

@ -285,9 +285,8 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
guard let article = coordinator.articles.articleAtRow(indexPath.row) else {
return
}
if feed == article.feed {
tableView.reloadRows(at: [indexPath], with: .none)
return
if article.feed == feed, let cell = tableView.cellForRow(at: indexPath) as? MasterTimelineTableViewCell, let image = avatarFor(article) {
cell.setAvatarImage(image)
}
}
}
@ -304,8 +303,8 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
return
}
for author in authors {
if author.avatarURL == avatarURL {
tableView.reloadRows(at: [indexPath], with: .none)
if author.avatarURL == avatarURL, let cell = tableView.cellForRow(at: indexPath) as? MasterTimelineTableViewCell, let image = avatarFor(article) {
cell.setAvatarImage(image)
}
}
}
@ -323,8 +322,8 @@ class MasterTimelineViewController: UITableViewController, UndoableCommandRunner
guard let article = coordinator.articles.articleAtRow(indexPath.row), let articleFaviconURL = article.feed?.faviconURL else {
return
}
if faviconURL == articleFaviconURL {
tableView.reloadRows(at: [indexPath], with: .none)
if faviconURL == articleFaviconURL, let cell = tableView.cellForRow(at: indexPath) as? MasterTimelineTableViewCell, let image = avatarFor(article) {
cell.setAvatarImage(image)
return
}