forked from shadowfacts/Tusker
Fix crash when hashtag search results include duplicate
This commit is contained in:
parent
9891b601a8
commit
4249ab30ca
|
@ -295,7 +295,10 @@ class SearchResultsViewController: UIViewController, CollectionViewController {
|
||||||
}
|
}
|
||||||
if !results.hashtags.isEmpty && resultTypes.contains(.hashtags) {
|
if !results.hashtags.isEmpty && resultTypes.contains(.hashtags) {
|
||||||
snapshot.appendSections([.hashtags])
|
snapshot.appendSections([.hashtags])
|
||||||
snapshot.appendItems(results.hashtags.map { .hashtag($0) }, toSection: .hashtags)
|
// mastodon sometimes includes duplicate hashtags with the same name but different urls
|
||||||
|
// (e.g., containing %C3%B8 vs o)
|
||||||
|
let uniqueHashtags = results.hashtags.uniques(by: \.name)
|
||||||
|
snapshot.appendItems(uniqueHashtags.map { .hashtag($0) }, toSection: .hashtags)
|
||||||
}
|
}
|
||||||
if !results.statuses.isEmpty && resultTypes.contains(.statuses) {
|
if !results.statuses.isEmpty && resultTypes.contains(.statuses) {
|
||||||
snapshot.appendSections([.statuses])
|
snapshot.appendSections([.statuses])
|
||||||
|
|
Loading…
Reference in New Issue