forked from shadowfacts/Tusker
Fix crash when refreshing profile before it has loaded
This commit is contained in:
parent
95f9fad673
commit
a18dfc38af
|
@ -100,7 +100,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
}
|
||||
case .loading:
|
||||
break
|
||||
case .loaded, .addedHeader:
|
||||
case .loaded, .setupInitialSnapshot:
|
||||
var snapshot = dataSource.snapshot()
|
||||
snapshot.reconfigureItems([.header(id)])
|
||||
dataSource.apply(snapshot, animatingDifferences: true)
|
||||
|
@ -183,7 +183,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
snapshot.appendItems([.header(accountID)], toSection: .header)
|
||||
await apply(snapshot, animatingDifferences: false)
|
||||
|
||||
state = .addedHeader
|
||||
state = .setupInitialSnapshot
|
||||
|
||||
await controller.loadInitial()
|
||||
await tryLoadPinned()
|
||||
|
@ -225,6 +225,12 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
|||
}
|
||||
|
||||
@objc func refresh() {
|
||||
guard case .loaded = state else {
|
||||
#if !targetEnvironment(macCatalyst)
|
||||
collectionView.refreshControl?.endRefreshing()
|
||||
#endif
|
||||
return
|
||||
}
|
||||
Task {
|
||||
// TODO: coalesce these data source updates
|
||||
// TODO: refresh profile
|
||||
|
@ -242,7 +248,7 @@ extension ProfileStatusesViewController {
|
|||
enum State {
|
||||
case unloaded
|
||||
case loading
|
||||
case addedHeader
|
||||
case setupInitialSnapshot
|
||||
case loaded
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue