From 490d48c63598b89c8b98adac9489c4a35abd55e1 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 2 Apr 2024 21:16:09 -0400 Subject: [PATCH] Fix loading indicator never disappearing when presenting gallery from status with >4 attachments --- .../GalleryPresentationAnimationController.swift | 4 ---- .../Sources/GalleryVC/GalleryViewController.swift | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift index 6d789b72..1a58ec06 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift @@ -109,8 +109,6 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated itemViewController.addContent() transitionContext.completeTransition(true) - - to.presentationAnimationCompleted() } animator.startAnimation() @@ -132,8 +130,6 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated } animator.addCompletion { _ in transitionContext.completeTransition(!transitionContext.transitionWasCancelled) - - to.presentationAnimationCompleted() } animator.startAnimation() } diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift index 7d238ef5..825084d0 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryViewController.swift @@ -68,6 +68,17 @@ public class GalleryViewController: UIPageViewController { setViewControllers([makeItemVC(index: initialItemIndex)], direction: .forward, animated: false) } + public override func viewDidAppear(_ animated: Bool) { + super.viewDidAppear(animated) + + if animated { + // Wait until the transition is no longer in-progress, otherwise things will just get deferred again. + DispatchQueue.main.async { + self.presentationAnimationCompleted() + } + } + } + public override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated)