From c256fb4cbd79e7449d8d6d79945b9d919987cafa Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 26 Nov 2022 17:33:58 -0500 Subject: [PATCH] When refreshing timeline, hide activity indicator as soon as loadNewer completes --- .../Timeline/TimelineViewController.swift | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Tusker/Screens/Timeline/TimelineViewController.swift b/Tusker/Screens/Timeline/TimelineViewController.swift index 8ca57ed8..50281e0b 100644 --- a/Tusker/Screens/Timeline/TimelineViewController.swift +++ b/Tusker/Screens/Timeline/TimelineViewController.swift @@ -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 } }