When refreshing timeline, hide activity indicator as soon as loadNewer completes

This commit is contained in:
Shadowfacts 2022-11-26 17:33:58 -05:00
parent 21299c8eb8
commit c256fb4cbd
1 changed files with 12 additions and 4 deletions

View File

@ -312,16 +312,24 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
Task {
if case .notLoadedInitial = controller.state {
await controller.loadInitial()
#if !targetEnvironment(macCatalyst)
collectionView.refreshControl?.endRefreshing()
#endif
} else {
@MainActor
func loadNewerAndEndRefreshing() async {
await controller.loadNewer()
#if !targetEnvironment(macCatalyst)
collectionView.refreshControl?.endRefreshing()
#endif
}
// I'm not sure whether this should move into TimelineLikeController/TimelineLikeCollectionViewController
let (_, presentItems) = await (controller.loadNewer(), try? loadInitial())
let (_, presentItems) = await (loadNewerAndEndRefreshing(), try? loadInitial())
if let presentItems, !presentItems.isEmpty {
insertPresentItemsIfNecessary(presentItems)
}
}
#if !targetEnvironment(macCatalyst)
collectionView.refreshControl?.endRefreshing()
#endif
}
}