forked from mirrors/linphone-iphone
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:
parent
965ee5a476
commit
f85e0b5118
1 changed files with 7 additions and 3 deletions
|
|
@ -113,7 +113,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
||||||
|
|
||||||
override func viewWillDisappear(_ animated: Bool) {
|
override func viewWillDisappear(_ animated: Bool) {
|
||||||
if ChatConversationTableViewModel.sharedModel.getNBMessages() > 0 {
|
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, name: Notification.Name("LinphoneFriendPresenceUpdate"), object: nil)
|
||||||
NotificationCenter.default.removeObserver(self)
|
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)
|
self.collectionView.scrollToItem(at: IndexPath(row: messageIndex, section: 0), at: .bottom, animated: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func scrollToBottom(animated: Bool){
|
func scrollToBottom(animated: Bool, async: Bool = true){
|
||||||
DispatchQueue.main.async{
|
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)
|
self.collectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .top, animated: animated)
|
||||||
}
|
}
|
||||||
ChatConversationViewSwift.markAsRead(ChatConversationViewModel.sharedModel.chatRoom?.getCobject)
|
ChatConversationViewSwift.markAsRead(ChatConversationViewModel.sharedModel.chatRoom?.getCobject)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue