diff --git a/apps/ios/Shared/Views/Chat/ReverseList.swift b/apps/ios/Shared/Views/Chat/ReverseList.swift index 5852db421e..bb434de3ad 100644 --- a/apps/ios/Shared/Views/Chat/ReverseList.swift +++ b/apps/ios/Shared/Views/Chat/ReverseList.swift @@ -224,9 +224,10 @@ struct ReverseList: UIViewControllerRepresentable { func update(items: [ChatItem], gap: ChatGap?) { var snapshot = NSDiffableDataSourceSnapshot() + let originalSize = renderedItems.count if let gap = gap { var itemsCopy = items - let blanks = (0..: UIViewControllerRepresentable { snapshot.appendSections([.main]) snapshot.appendItems(renderedItems) dataSource.defaultRowAnimation = .none - dataSource.apply( - snapshot, - animatingDifferences: itemCount != 0 && abs(renderedItems.count - itemCount) == 1 - ) + + let countDiff = max(0, renderedItems.count - originalSize) + if tableView.contentOffset.y == 0, originalSize > countDiff { + dataSource.apply( + snapshot, + animatingDifferences: false + ) + + tableView.scrollToRow( + at: IndexPath(row: countDiff, section: 0), + at: .top, + animated: false + ) + } else { + UITableView.performWithoutAnimation { + tableView.beginUpdates() + dataSource.apply( + snapshot, + animatingDifferences: false + ) + tableView.endUpdates() + } + } + // Sets content offset on initial load if itemCount == 0 { tableView.setContentOffset(