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 {