From d404b3b8da4cff4bb981c02a473bf28f306ff47c Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 31 Oct 2026 10:43:14 -0700 Subject: [PATCH] =?UTF-8?q?Update=20cells=20about=20to=20be=20displayed,?= =?UTF-8?q?=20so=20thumbnail=20that=20arrives=20after=20the=20cell=20was?= =?UTF-8?q?=20prepared=20doesn=E2=80=99t=20leave=20the=20row=20gray.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MainTimelineViewController.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/iOS/MainTimeline/MainTimelineViewController.swift b/iOS/MainTimeline/MainTimelineViewController.swift index 12c5fa3e7..9d6378ea7 100644 --- a/iOS/MainTimeline/MainTimelineViewController.swift +++ b/iOS/MainTimeline/MainTimelineViewController.swift @@ -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 }