From 057c33e680dd67ea795ad9bcf4b68f0e015b5283 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Thu, 21 Sep 2023 11:57:11 +0100 Subject: [PATCH] Replace timeline animation delay with a check on the item count. (#1777) --- .../View/Timeline/TimelineTableViewController.swift | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/ElementX/Sources/Screens/RoomScreen/View/Timeline/TimelineTableViewController.swift b/ElementX/Sources/Screens/RoomScreen/View/Timeline/TimelineTableViewController.swift index 7d25fe1a4..9abb220db 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/Timeline/TimelineTableViewController.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/Timeline/TimelineTableViewController.swift @@ -83,8 +83,6 @@ class TimelineTableViewController: UIViewController { private let paginateBackwardsPublisher = PassthroughSubject() /// Whether or not the view has been shown on screen yet. private var hasAppearedOnce = false - /// Whether the scroll and the animations should happen - private var shouldAnimate = false init(coordinator: UITimelineView.Coordinator, timelineStyle: TimelineStyle, @@ -134,10 +132,6 @@ class TimelineTableViewController: UIViewController { tableView.contentOffset.y = -1 hasAppearedOnce = true paginateBackwardsPublisher.send() - - DispatchQueue.main.asyncAfter(deadline: .now() + 2) { - self.shouldAnimate = true - } } override func viewWillLayoutSubviews() { @@ -207,8 +201,8 @@ class TimelineTableViewController: UIViewController { let currentSnapshot = dataSource.snapshot() MXLog.verbose("DIFF: \(snapshot.itemIdentifiers.difference(from: currentSnapshot.itemIdentifiers))") - // We only animate when new items come at the end of the timeline - let animated = shouldAnimate && + // We only animate when new items come at the end of the timeline, ignoring transitions through empty. + let animated = currentSnapshot.numberOfItems > 0 && snapshot.numberOfItems > 0 && snapshot.itemIdentifiers.first != currentSnapshot.itemIdentifiers.first dataSource.apply(snapshot, animatingDifferences: animated) }