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:
|
case .loading:
|
||||||
break
|
break
|
||||||
case .loaded, .addedHeader:
|
case .loaded, .setupInitialSnapshot:
|
||||||
var snapshot = dataSource.snapshot()
|
var snapshot = dataSource.snapshot()
|
||||||
snapshot.reconfigureItems([.header(id)])
|
snapshot.reconfigureItems([.header(id)])
|
||||||
dataSource.apply(snapshot, animatingDifferences: true)
|
dataSource.apply(snapshot, animatingDifferences: true)
|
||||||
|
@ -183,7 +183,7 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
||||||
snapshot.appendItems([.header(accountID)], toSection: .header)
|
snapshot.appendItems([.header(accountID)], toSection: .header)
|
||||||
await apply(snapshot, animatingDifferences: false)
|
await apply(snapshot, animatingDifferences: false)
|
||||||
|
|
||||||
state = .addedHeader
|
state = .setupInitialSnapshot
|
||||||
|
|
||||||
await controller.loadInitial()
|
await controller.loadInitial()
|
||||||
await tryLoadPinned()
|
await tryLoadPinned()
|
||||||
|
@ -225,6 +225,12 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func refresh() {
|
@objc func refresh() {
|
||||||
|
guard case .loaded = state else {
|
||||||
|
#if !targetEnvironment(macCatalyst)
|
||||||
|
collectionView.refreshControl?.endRefreshing()
|
||||||
|
#endif
|
||||||
|
return
|
||||||
|
}
|
||||||
Task {
|
Task {
|
||||||
// TODO: coalesce these data source updates
|
// TODO: coalesce these data source updates
|
||||||
// TODO: refresh profile
|
// TODO: refresh profile
|
||||||
|
@ -242,7 +248,7 @@ extension ProfileStatusesViewController {
|
||||||
enum State {
|
enum State {
|
||||||
case unloaded
|
case unloaded
|
||||||
case loading
|
case loading
|
||||||
case addedHeader
|
case setupInitialSnapshot
|
||||||
case loaded
|
case loaded
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue