From 751f81aafdffb149e87523788013d2084611a1d8 Mon Sep 17 00:00:00 2001 From: Jakub Kaspar Date: Sun, 30 Apr 2023 11:46:03 -0500 Subject: [PATCH] Don't animate hiding typing indicator if also inserting a message --- .../View Controllers/AdvancedExampleViewController.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Example/Sources/View Controllers/AdvancedExampleViewController.swift b/Example/Sources/View Controllers/AdvancedExampleViewController.swift index 4892390f..d575e64c 100644 --- a/Example/Sources/View Controllers/AdvancedExampleViewController.swift +++ b/Example/Sources/View Controllers/AdvancedExampleViewController.swift @@ -74,9 +74,9 @@ final class AdvancedExampleViewController: ChatViewController { MockSocket.shared.connect(with: [SampleData.shared.nathan, SampleData.shared.wu]) .onTypingStatus { [weak self] in - self?.setTypingIndicatorViewHidden(false) + self?.setTypingIndicatorViewHidden(false, animated: true) }.onNewMessage { [weak self] message in - self?.setTypingIndicatorViewHidden(true, performUpdates: { + self?.setTypingIndicatorViewHidden(true, animated: false, performUpdates: { self?.insertMessage(message) }) } @@ -190,9 +190,9 @@ final class AdvancedExampleViewController: ChatViewController { return messageList[indexPath.section].user == messageList[indexPath.section + 1].user } - func setTypingIndicatorViewHidden(_ isHidden: Bool, performUpdates updates: (() -> Void)? = nil) { + func setTypingIndicatorViewHidden(_ isHidden: Bool, animated: Bool, performUpdates updates: (() -> Void)? = nil) { updateTitleView(title: "MessageKit", subtitle: isHidden ? "2 Online" : "Typing...") - setTypingIndicatorViewHidden(isHidden, animated: true, whilePerforming: updates) { [weak self] success in + setTypingIndicatorViewHidden(isHidden, animated: animated, whilePerforming: updates) { [weak self] success in if success, self?.isLastSectionVisible() == true { self?.messagesCollectionView.scrollToLastItem(animated: true) }