From 1f18fca7221740cbfe57d54d81a7f276c38902e9 Mon Sep 17 00:00:00 2001 From: Levitating Pineapple Date: Thu, 15 Aug 2024 16:06:39 +0300 Subject: [PATCH] chat new message animation --- apps/ios/Shared/Views/Chat/ReverseList.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/ios/Shared/Views/Chat/ReverseList.swift b/apps/ios/Shared/Views/Chat/ReverseList.swift index 4ce6a1a065..6e1e73ca63 100644 --- a/apps/ios/Shared/Views/Chat/ReverseList.swift +++ b/apps/ios/Shared/Views/Chat/ReverseList.swift @@ -175,10 +175,13 @@ struct ReverseList: UIV var snapshot = NSDiffableDataSourceSnapshot() snapshot.appendSections([.main]) snapshot.appendItems(items) - dataSource.defaultRowAnimation = .none - dataSource.apply( - snapshot, - animatingDifferences: itemCount != 0 && abs(items.count - itemCount) == 1 + dataSource.defaultRowAnimation = items.count > itemCount + ? .top // Added items slide in from the bottom (top reversed) + : .none // Replacing or removing rows is not animated + let countChange = abs(items.count - itemCount) + dataSource.apply(snapshot, animatingDifferences: + countChange > 0 && // Avoid animating initial load + countChange < 5 // Avoid animating page loads ) itemCount = items.count }