Fix creating list on iPad overwriting previous item navigation stack
This commit is contained in:
parent
948eff1f7e
commit
b515664db3
|
@ -213,23 +213,7 @@ class MainSidebarViewController: UIViewController {
|
||||||
exploreSnapshot.expand([.listsHeader])
|
exploreSnapshot.expand([.listsHeader])
|
||||||
exploreSnapshot.append(lists.map { .list($0) }, to: .listsHeader)
|
exploreSnapshot.append(lists.map { .list($0) }, to: .listsHeader)
|
||||||
exploreSnapshot.append([.addList], to: .listsHeader)
|
exploreSnapshot.append([.addList], to: .listsHeader)
|
||||||
var selectedItem: Item?
|
self.dataSource.apply(exploreSnapshot, to: .lists)
|
||||||
if let selectedIndexPath = collectionView.indexPathsForSelectedItems?.first,
|
|
||||||
let item = dataSource.itemIdentifier(for: selectedIndexPath) {
|
|
||||||
if case .list(let list) = item,
|
|
||||||
let newList = lists.first(where: { $0.id == list.id }) {
|
|
||||||
selectedItem = .list(newList)
|
|
||||||
} else {
|
|
||||||
selectedItem = item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.dataSource.apply(exploreSnapshot, to: .lists) {
|
|
||||||
if let selectedItem,
|
|
||||||
let indexPath = self.dataSource.indexPath(for: selectedItem) {
|
|
||||||
self.collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredVertically)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
|
@ -255,8 +239,6 @@ class MainSidebarViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func reloadSavedHashtags() {
|
@objc private func reloadSavedHashtags() {
|
||||||
let selected = collectionView.indexPathsForSelectedItems?.first
|
|
||||||
|
|
||||||
var hashtagsSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
var hashtagsSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||||
hashtagsSnapshot.append([.savedHashtagsHeader])
|
hashtagsSnapshot.append([.savedHashtagsHeader])
|
||||||
hashtagsSnapshot.expand([.savedHashtagsHeader])
|
hashtagsSnapshot.expand([.savedHashtagsHeader])
|
||||||
|
@ -265,16 +247,10 @@ class MainSidebarViewController: UIViewController {
|
||||||
}
|
}
|
||||||
hashtagsSnapshot.append(hashtags, to: .savedHashtagsHeader)
|
hashtagsSnapshot.append(hashtags, to: .savedHashtagsHeader)
|
||||||
hashtagsSnapshot.append([.addSavedHashtag], to: .savedHashtagsHeader)
|
hashtagsSnapshot.append([.addSavedHashtag], to: .savedHashtagsHeader)
|
||||||
self.dataSource.apply(hashtagsSnapshot, to: .savedHashtags, animatingDifferences: false) {
|
self.dataSource.apply(hashtagsSnapshot, to: .savedHashtags)
|
||||||
if let selected = selected {
|
|
||||||
self.collectionView.selectItem(at: selected, animated: false, scrollPosition: .centeredVertically)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func reloadSavedInstances() {
|
@objc private func reloadSavedInstances() {
|
||||||
let selected = collectionView.indexPathsForSelectedItems?.first
|
|
||||||
|
|
||||||
var instancesSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
var instancesSnapshot = NSDiffableDataSourceSectionSnapshot<Item>()
|
||||||
instancesSnapshot.append([.savedInstancesHeader])
|
instancesSnapshot.append([.savedInstancesHeader])
|
||||||
instancesSnapshot.expand([.savedInstancesHeader])
|
instancesSnapshot.expand([.savedInstancesHeader])
|
||||||
|
@ -283,11 +259,7 @@ class MainSidebarViewController: UIViewController {
|
||||||
}
|
}
|
||||||
instancesSnapshot.append(instances, to: .savedInstancesHeader)
|
instancesSnapshot.append(instances, to: .savedInstancesHeader)
|
||||||
instancesSnapshot.append([.addSavedInstance], to: .savedInstancesHeader)
|
instancesSnapshot.append([.addSavedInstance], to: .savedInstancesHeader)
|
||||||
self.dataSource.apply(instancesSnapshot, to: .savedInstances, animatingDifferences: false) {
|
self.dataSource.apply(instancesSnapshot, to: .savedInstances)
|
||||||
if let selected = selected {
|
|
||||||
self.collectionView.selectItem(at: selected, animated: false, scrollPosition: .centeredVertically)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func preferencesChanged() {
|
@objc private func preferencesChanged() {
|
||||||
|
|
Loading…
Reference in New Issue