Merge pull request #432 from mastodon/fix-auto-complete-crash
Fix auto complete items may raise crash issue
This commit is contained in:
commit
3bdd9dc4aa
|
@ -46,7 +46,7 @@ final class AutoCompleteViewModel {
|
||||||
|
|
||||||
var snapshot = NSDiffableDataSourceSnapshot<AutoCompleteSection, AutoCompleteItem>()
|
var snapshot = NSDiffableDataSourceSnapshot<AutoCompleteSection, AutoCompleteItem>()
|
||||||
snapshot.appendSections([.main])
|
snapshot.appendSections([.main])
|
||||||
snapshot.appendItems(items, toSection: .main)
|
snapshot.appendItems(items.removingDuplicates(), toSection: .main)
|
||||||
if let currentState = self.stateMachine.currentState {
|
if let currentState = self.stateMachine.currentState {
|
||||||
switch currentState {
|
switch currentState {
|
||||||
case is State.Loading, is State.Fail:
|
case is State.Loading, is State.Fail:
|
||||||
|
|
|
@ -32,7 +32,7 @@ extension DiscoveryHashtagsViewModel {
|
||||||
snapshot.appendSections([.hashtags])
|
snapshot.appendSections([.hashtags])
|
||||||
|
|
||||||
let items = hashtags.map { DiscoveryItem.hashtag($0) }
|
let items = hashtags.map { DiscoveryItem.hashtag($0) }
|
||||||
snapshot.appendItems(items, toSection: .hashtags)
|
snapshot.appendItems(items.removingDuplicates(), toSection: .hashtags)
|
||||||
|
|
||||||
diffableDataSource.apply(snapshot)
|
diffableDataSource.apply(snapshot)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue