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)
|
.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> {
|
private func createDataSource() -> UICollectionViewDiffableDataSource<Section, Item> {
|
||||||
|
@ -181,11 +174,18 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
||||||
private func load() async {
|
private func load() async {
|
||||||
guard isViewLoaded,
|
guard isViewLoaded,
|
||||||
let accountID,
|
let accountID,
|
||||||
state == .setupInitialSnapshot,
|
state == .unloaded,
|
||||||
mastodonController.persistentContainer.account(for: accountID) != nil else {
|
mastodonController.persistentContainer.account(for: accountID) != nil else {
|
||||||
return
|
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 controller.loadInitial()
|
||||||
await tryLoadPinned()
|
await tryLoadPinned()
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,7 @@ class ProfileViewController: UIViewController {
|
||||||
assert(!animated)
|
assert(!animated)
|
||||||
// if old doesn't exist, we're selecting the initial view controller, so moving the header around isn't necessary
|
// if old doesn't exist, we're selecting the initial view controller, so moving the header around isn't necessary
|
||||||
new.initialHeaderMode = .createView
|
new.initialHeaderMode = .createView
|
||||||
|
new.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
embedChild(new)
|
embedChild(new)
|
||||||
self.currentIndex = index
|
self.currentIndex = index
|
||||||
state = .idle
|
state = .idle
|
||||||
|
@ -221,6 +222,7 @@ class ProfileViewController: UIViewController {
|
||||||
new.collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: additionalHeightNeededToMatchContentOffset, right: 0)
|
new.collectionView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: additionalHeightNeededToMatchContentOffset, right: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
embedChild(new)
|
embedChild(new)
|
||||||
new.view.transform = CGAffineTransform(translationX: direction * view.bounds.width, y: yTranslationToMatchOldContentOffset)
|
new.view.transform = CGAffineTransform(translationX: direction * view.bounds.width, y: yTranslationToMatchOldContentOffset)
|
||||||
|
|
||||||
|
@ -256,6 +258,7 @@ class ProfileViewController: UIViewController {
|
||||||
animator.startAnimation()
|
animator.startAnimation()
|
||||||
} else {
|
} else {
|
||||||
old.removeViewAndController()
|
old.removeViewAndController()
|
||||||
|
new.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
embedChild(new)
|
embedChild(new)
|
||||||
completion?(true)
|
completion?(true)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue