From ae7ca9c91cd432c95e2e1869189c2d4bd98e6866 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 11 Feb 2023 18:23:53 -0500 Subject: [PATCH] Fix wrong cells on trending links screen being selectable --- .../Explore/TrendingLinksViewController.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Tusker/Screens/Explore/TrendingLinksViewController.swift b/Tusker/Screens/Explore/TrendingLinksViewController.swift index 1ff4324f..578cc48b 100644 --- a/Tusker/Screens/Explore/TrendingLinksViewController.swift +++ b/Tusker/Screens/Explore/TrendingLinksViewController.swift @@ -175,7 +175,7 @@ class TrendingLinksViewController: UIViewController, CollectionViewController { do { let request = Client.getTrendingLinks(offset: origSnapshot.itemIdentifiers.count) let (links, _) = try await mastodonController.run(request) - snapshot = origSnapshot + var snapshot = origSnapshot snapshot.appendItems(links.map { .link($0) }, toSection: .links) await dataSource.apply(snapshot) } catch { @@ -235,6 +235,14 @@ extension TrendingLinksViewController { hasher.combine(loading) } } + + var shouldSelect: Bool { + if case .link(_) = self { + return true + } else { + return false + } + } } } @@ -248,6 +256,10 @@ extension TrendingLinksViewController: UICollectionViewDelegate { } } + func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { + return dataSource.itemIdentifier(for: indexPath)?.shouldSelect ?? false + } + func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { guard case .link(let card) = dataSource.itemIdentifier(for: indexPath), let url = URL(card.url) else {