forked from shadowfacts/Tusker
Fix wrong cells on trending links screen being selectable
This commit is contained in:
parent
841119949b
commit
ae7ca9c91c
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue