diff --git a/Tusker/Screens/Profile/ProfileStatusesViewController.swift b/Tusker/Screens/Profile/ProfileStatusesViewController.swift index 92e74480..995a4991 100644 --- a/Tusker/Screens/Profile/ProfileStatusesViewController.swift +++ b/Tusker/Screens/Profile/ProfileStatusesViewController.swift @@ -106,13 +106,6 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie } } .store(in: &cancellables) - - var snapshot = NSDiffableDataSourceSnapshot() - snapshot.appendSections([.header, .pinned, .statuses]) - snapshot.appendItems([.header(accountID)], toSection: .header) - dataSource.apply(snapshot, animatingDifferences: false) - - state = .setupInitialSnapshot } private func createDataSource() -> UICollectionViewDiffableDataSource { @@ -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() + snapshot.appendSections([.header, .pinned, .statuses]) + snapshot.appendItems([.header(accountID)], toSection: .header) + await apply(snapshot, animatingDifferences: false) + + state = .setupInitialSnapshot + await controller.loadInitial() await tryLoadPinned() diff --git a/Tusker/Screens/Profile/ProfileViewController.swift b/Tusker/Screens/Profile/ProfileViewController.swift index 2fdc6865..014d35f7 100644 --- a/Tusker/Screens/Profile/ProfileViewController.swift +++ b/Tusker/Screens/Profile/ProfileViewController.swift @@ -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) }