Show max. 10 items in history (IOS-141)

This commit is contained in:
Nathan Mattes 2023-09-17 15:16:25 +02:00
parent 7abc536d01
commit ed5a0f3abc
1 changed files with 4 additions and 2 deletions

View File

@ -53,10 +53,12 @@ extension SearchHistoryViewModel {
return users + hashtags
}
let mostRecentItems = Array(items.prefix(10))
var snapshot = NSDiffableDataSourceSnapshot<SearchHistorySection, SearchHistoryItem>()
snapshot.appendSections([.main])
snapshot.appendItems(items, toSection: .main)
await diffableDataSource.apply(snapshot, animatingDifferences: false)
snapshot.appendItems(mostRecentItems, toSection: .main)
await diffableDataSource.apply(snapshot, animatingDifferences: true)
} catch {
// do nothing
}