Fix message display missing when going from a conversation with few messages (not enough to fill screen) to conversation with many messages

This commit is contained in:
Christophe Deschamps 2024-02-16 08:03:52 +01:00
parent 9094c9cea8
commit c02dcc754e

View file

@ -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,10 +130,14 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
self.collectionView.scrollToItem(at: IndexPath(row: messageIndex, section: 0), at: .bottom, animated: false)
}
func scrollToBottom(animated: Bool){
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)
if self.floatingScrollButton != nil && self.floatingScrollBackground != nil {
self.floatingScrollButton!.isHidden = true