From f85e0b51180900d0184f1d9ec626a1b001b5afcc Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Fri, 16 Feb 2024 08:03:52 +0100 Subject: [PATCH] Fix message display missing when going from a conversation with few messages (not enough to fill screen) to conversation with many messages --- .../Chat/Views/ChatConversationTableViewSwift.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Classes/Swift/Chat/Views/ChatConversationTableViewSwift.swift b/Classes/Swift/Chat/Views/ChatConversationTableViewSwift.swift index 84d0a326a..df22ee135 100644 --- a/Classes/Swift/Chat/Views/ChatConversationTableViewSwift.swift +++ b/Classes/Swift/Chat/Views/ChatConversationTableViewSwift.swift @@ -113,7 +113,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour override func viewWillDisappear(_ animated: Bool) { if ChatConversationTableViewModel.sharedModel.getNBMessages() > 0 { - scrollToBottom(animated: false) + scrollToBottom(animated: false, async:false) } NotificationCenter.default.removeObserver(self, name: Notification.Name("LinphoneFriendPresenceUpdate"), object: nil) NotificationCenter.default.removeObserver(self) @@ -130,8 +130,12 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour self.collectionView.scrollToItem(at: IndexPath(row: messageIndex, section: 0), at: .bottom, animated: false) } - func scrollToBottom(animated: Bool){ - DispatchQueue.main.async{ + func scrollToBottom(animated: Bool, async: Bool = true){ + if (async) { + DispatchQueue.main.async{ + self.collectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .top, animated: animated) + } + } else { self.collectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .top, animated: animated) } ChatConversationViewSwift.markAsRead(ChatConversationViewModel.sharedModel.chatRoom?.getCobject)