forked from shadowfacts/Tusker
Fix crash when opening My Profile on iPad
This commit is contained in:
parent
220c8050b1
commit
1a767ff910
|
@ -106,13 +106,6 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.header, .pinned, .statuses])
|
||||
snapshot.appendItems([.header(accountID)], toSection: .header)
|
||||
dataSource.apply(snapshot, animatingDifferences: false)
|
||||
|
||||
state = .setupInitialSnapshot
|
||||
}
|
||||
|
||||
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||
|
@ -181,11 +174,18 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
private func load() async {
|
||||
guard isViewLoaded,
|
||||
let accountID,
|
||||
state == .setupInitialSnapshot,
|
||||
state == .unloaded,
|
||||
mastodonController.persistentContainer.account(for: accountID) != nil else {
|
||||
return
|
||||
}
|
||||
|
||||
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>()
|
||||
snapshot.appendSections([.header, .pinned, .statuses])
|
||||
snapshot.appendItems([.header(accountID)], toSection: .header)
|
||||
await apply(snapshot, animatingDifferences: false)
|
||||
|
||||
state = .setupInitialSnapshot
|
||||
|
||||
await controller.loadInitial()
|
||||
await tryLoadPinned()
|
||||
|
||||
|
|
|
@ -152,6 +152,7 @@ class ProfileViewController: UIViewController {
|
|||
assert(!animated)
|
||||
// if old doesn't exist, we're selecting the initial view controller, so moving the header around isn't necessary
|
||||
new.initialHeaderMode = .createView
|
||||
new.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
embedChild(new)
|
||||
self.currentIndex = index
|
||||
state = .idle
|
||||
|
@ -221,6 +222,7 @@ class ProfileViewController: UIViewController {
|
|||
new.collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: additionalHeightNeededToMatchContentOffset, right: 0)
|
||||
}
|
||||
|
||||
new.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
embedChild(new)
|
||||
new.view.transform = CGAffineTransform(translationX: direction * view.bounds.width, y: yTranslationToMatchOldContentOffset)
|
||||
|
||||
|
@ -256,6 +258,7 @@ class ProfileViewController: UIViewController {
|
|||
animator.startAnimation()
|
||||
} else {
|
||||
old.removeViewAndController()
|
||||
new.view.translatesAutoresizingMaskIntoConstraints = false
|
||||
embedChild(new)
|
||||
completion?(true)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue