Fix sidebar item getting deselected on add list/instance/hashtag
This commit is contained in:
parent
eba2e17479
commit
9f0883d0cb
|
@ -159,29 +159,47 @@ class MainSidebarViewController: UIViewController {
|
|||
exploreSnapshot.append(lists.map { .list($0) }, to: .listsHeader)
|
||||
exploreSnapshot.append([.addList], to: .listsHeader)
|
||||
DispatchQueue.main.async {
|
||||
self.dataSource.apply(exploreSnapshot, to: .lists)
|
||||
let selected = self.collectionView.indexPathsForSelectedItems?.first
|
||||
|
||||
self.dataSource.apply(exploreSnapshot, to: .lists) {
|
||||
if let selected = selected {
|
||||
self.collectionView.selectItem(at: selected, animated: false, scrollPosition: .centeredVertically)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func reloadSavedHashtags() {
|
||||
let selected = collectionView.indexPathsForSelectedItems?.first
|
||||
|
||||
var hashtagsSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||
hashtagsSnapshot.append([.savedHashtagsHeader])
|
||||
hashtagsSnapshot.expand([.savedHashtagsHeader])
|
||||
let sortedHashtags = SavedDataManager.shared.sortedHashtags(for: mastodonController.accountInfo!)
|
||||
hashtagsSnapshot.append(sortedHashtags.map { .savedHashtag($0) }, to: .savedHashtagsHeader)
|
||||
hashtagsSnapshot.append([.addSavedHashtag], to: .savedHashtagsHeader)
|
||||
self.dataSource.apply(hashtagsSnapshot, to: .savedHashtags, animatingDifferences: false)
|
||||
self.dataSource.apply(hashtagsSnapshot, to: .savedHashtags, animatingDifferences: false) {
|
||||
if let selected = selected {
|
||||
self.collectionView.selectItem(at: selected, animated: false, scrollPosition: .centeredVertically)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func reloadSavedInstances() {
|
||||
let selected = collectionView.indexPathsForSelectedItems?.first
|
||||
|
||||
var instancesSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||
instancesSnapshot.append([.savedInstancesHeader])
|
||||
instancesSnapshot.expand([.savedInstancesHeader])
|
||||
let sortedInstances = SavedDataManager.shared.savedInstances(for: mastodonController.accountInfo!)
|
||||
instancesSnapshot.append(sortedInstances.map { .savedInstance($0) }, to: .savedInstancesHeader)
|
||||
instancesSnapshot.append([.addSavedInstance], to: .savedInstancesHeader)
|
||||
self.dataSource.apply(instancesSnapshot, to: .savedInstances, animatingDifferences: false)
|
||||
self.dataSource.apply(instancesSnapshot, to: .savedInstances, animatingDifferences: false) {
|
||||
if let selected = selected {
|
||||
self.collectionView.selectItem(at: selected, animated: false, scrollPosition: .centeredVertically)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// todo: deduplicate with ExploreViewController
|
||||
|
|
Loading…
Reference in New Issue