mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 00:31:14 +00:00
Update cells about to be displayed, so thumbnail that arrives after the cell was prepared doesn’t leave the row gray.
This commit is contained in:
1 parent
2aeb9e3d8b
commit
d404b3b8da
1 file changed
+17
@@ -598,6 +598,23 @@ extension MainTimelineViewController: UICollectionViewDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
/// Cells are configured before they’re displayed, and thumbnail notifications update only visible cells.
|
||||
func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
|
||||
guard let thumbnailMode, let cell = cell as? MainTimelineCell, let cellData = cell.cellData, let article = dataSource?.itemIdentifier(for: indexPath) else {
|
||||
return
|
||||
}
|
||||
let thumbnailURL = ArticleThumbnailFinder.shared.thumbnailURL(for: article, mode: thumbnailMode)
|
||||
if (thumbnailURL != nil) != cellData.showThumbnail {
|
||||
// The row’s height changes too.
|
||||
reloadCells([article])
|
||||
return
|
||||
}
|
||||
guard let thumbnailURL, let thumbnail = ArticleThumbnailFinder.shared.thumbnail(url: thumbnailURL, mode: thumbnailMode, articleTitle: article.title), thumbnail !== cellData.thumbnail else {
|
||||
return
|
||||
}
|
||||
cell.cellData = configure(article: article)
|
||||
}
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemsAt indexPaths: [IndexPath], point: CGPoint) -> UIContextMenuConfiguration? {
|
||||
guard let firstIndex = indexPaths.first, let dataSource, let article = dataSource.itemIdentifier(for: firstIndex) else { return nil }
|
||||
|
||||
|
||||
Reference in new issue
Block a user