From f41d3d2ac7dd376ad35c6da83dcbb7493f3d42a8 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 31 Oct 2026 11:57:36 -0700 Subject: [PATCH] =?UTF-8?q?Set=20only=20the=20image=20on=20the=20cell=20so?= =?UTF-8?q?=20each=20download=20doesn=E2=80=99t=20rebuild=20the=20whole=20?= =?UTF-8?q?cell.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Timeline/Cell/TimelineCellData.swift | 2 +- .../Timeline/Cell/TimelineTableCellView.swift | 10 ++++++++++ .../Timeline/TimelineViewController.swift | 4 ++-- iOS/MainTimeline/Cell/MainTimelineCell.swift | 14 ++++++++++---- iOS/MainTimeline/MainTimelineViewController.swift | 8 ++++---- 5 files changed, 27 insertions(+), 11 deletions(-) diff --git a/Mac/MainWindow/Timeline/Cell/TimelineCellData.swift b/Mac/MainWindow/Timeline/Cell/TimelineCellData.swift index 282ddfdb5..28c1b59b1 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineCellData.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineCellData.swift @@ -23,7 +23,7 @@ import Images let showFeedName: TimelineShowFeedName let iconImage: IconImage? // feed icon, user avatar, or favicon let showIcon: Bool // Make space even when icon is nil - var thumbnail: NSImage? + let thumbnail: NSImage? let showThumbnail: Bool // Make space even when thumbnail is nil let read: Bool let starred: Bool diff --git a/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift index 33ea84cc9..598a39cce 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -45,6 +45,16 @@ final class TimelineTableCellView: NSTableCellView { } } + /// The image shown now, which can be newer than `cellData.thumbnail`. Setting this leaves the rest of the cell as it is. + var thumbnail: NSImage? { + get { + thumbnailView.image + } + set { + thumbnailView.image = newValue + } + } + var isEmphasized: Bool = false { didSet { unreadIndicatorView.isEmphasized = isEmphasized diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index f359f1d1c..387edfac2 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -775,12 +775,12 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr guard let thumbnailMode, let url = notification.userInfo?[ArticleThumbnailFinder.urlKey] as? String else { return } - // The row already has room for the thumbnail, so the rest of the cell’s data stays as it is. + // The row already has room for the thumbnail, so only the image changes. tableView.enumerateAvailableRowViews { rowView, row in guard let article = articles.articleAtRow(row), ArticleThumbnailFinder.shared.thumbnailURL(for: article, mode: thumbnailMode) == url, let cell = cellForRowView(rowView) as? TimelineTableCellView, let thumbnail = ArticleThumbnailFinder.shared.thumbnail(url: url, mode: thumbnailMode, articleTitle: article.title) else { return } - cell.cellData?.thumbnail = thumbnail + cell.thumbnail = thumbnail } } diff --git a/iOS/MainTimeline/Cell/MainTimelineCell.swift b/iOS/MainTimeline/Cell/MainTimelineCell.swift index e2d137a74..0348f7213 100644 --- a/iOS/MainTimeline/Cell/MainTimelineCell.swift +++ b/iOS/MainTimeline/Cell/MainTimelineCell.swift @@ -32,6 +32,16 @@ final class MainTimelineCell: UICollectionViewCell { } } + /// The image shown now, which can be newer than `cellData.thumbnail`. Setting this leaves the rest of the cell as it is. + var thumbnail: UIImage? { + get { + thumbnailView.image + } + set { + thumbnailView.image = newValue + } + } + override init(frame: CGRect) { super.init(frame: frame) commonInit() @@ -126,10 +136,6 @@ final class MainTimelineCell: UICollectionViewCell { updateColors(active: showsAccentSelection) updateIndicatorView(active: showsAccentSelection) } - - func setIconImage(_ image: IconImage) { - iconView.iconImage = image - } } // MARK: - Private diff --git a/iOS/MainTimeline/MainTimelineViewController.swift b/iOS/MainTimeline/MainTimelineViewController.swift index d8db3d5b8..8626da583 100644 --- a/iOS/MainTimeline/MainTimelineViewController.swift +++ b/iOS/MainTimeline/MainTimelineViewController.swift @@ -609,10 +609,10 @@ extension MainTimelineViewController: UICollectionViewDelegate { reloadCells([article]) return } - guard let thumbnailURL, let thumbnail = ArticleThumbnailFinder.shared.thumbnail(url: thumbnailURL, mode: thumbnailMode, articleTitle: article.title), thumbnail !== cellData.thumbnail else { + guard let thumbnailURL, let thumbnail = ArticleThumbnailFinder.shared.thumbnail(url: thumbnailURL, mode: thumbnailMode, articleTitle: article.title), thumbnail !== cell.thumbnail else { return } - cell.cellData = configure(article: article) + cell.thumbnail = thumbnail } func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemsAt indexPaths: [IndexPath], point: CGPoint) -> UIContextMenuConfiguration? { @@ -1249,10 +1249,10 @@ private extension MainTimelineViewController { } // The row’s height already allows for the thumbnail, so only the cell’s contents change. for indexPath in collectionView.indexPathsForVisibleItems { - guard let article = dataSource.itemIdentifier(for: indexPath), ArticleThumbnailFinder.shared.thumbnailURL(for: article, mode: thumbnailMode) == url, let cell = collectionView.cellForItem(at: indexPath) as? MainTimelineCell else { + guard let article = dataSource.itemIdentifier(for: indexPath), ArticleThumbnailFinder.shared.thumbnailURL(for: article, mode: thumbnailMode) == url, let cell = collectionView.cellForItem(at: indexPath) as? MainTimelineCell, let thumbnail = ArticleThumbnailFinder.shared.thumbnail(url: url, mode: thumbnailMode, articleTitle: article.title) else { continue } - cell.cellData = configure(article: article) + cell.thumbnail = thumbnail } }