diff --git a/Classes/Swift/Chat/Views/ChatConversationTableViewSwift.swift b/Classes/Swift/Chat/Views/ChatConversationTableViewSwift.swift index 9855b8ff8..31e40ebdb 100644 --- a/Classes/Swift/Chat/Views/ChatConversationTableViewSwift.swift +++ b/Classes/Swift/Chat/Views/ChatConversationTableViewSwift.swift @@ -104,6 +104,31 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour } } + func scrollToBottom(){ + self.collectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .bottom, animated: true) + } + + func refreshData(){ + let indexBottom = self.collectionView.indexPathsForVisibleItems.sorted().first?.row + let offset = self.collectionView.contentOffset + print("MultilineMessageCell configure \(offset) \(indexBottom)") + collectionView.reloadData() + self.collectionView.scrollToItem(at: IndexPath(row: indexBottom! + 1, section: 0), at: .top, animated: false) + + /* + DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { + let offsetIndex = self.collectionView.contentOffset + print("MultilineMessageCell configure \(offsetIndex)") + self.collectionView.setContentOffset(CGPoint(x: self.collectionView.contentOffset.x, y: self.collectionView.contentOffset.y + offset.y + 10), animated: false) + } + */ + + //self.collectionView.scrollToItem(at: IndexPath(item: 1, section: 0), at: .bottom, animated: false) + //DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { + // self.scrollToBottom() + //} + } + // MARK: - UICollectionViewDataSource - func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MultilineMessageCell.reuseId, for: indexPath) as! MultilineMessageCell diff --git a/Classes/Swift/Chat/Views/ChatConversationViewSwift.swift b/Classes/Swift/Chat/Views/ChatConversationViewSwift.swift index e4348b28e..42391b14b 100644 --- a/Classes/Swift/Chat/Views/ChatConversationViewSwift.swift +++ b/Classes/Swift/Chat/Views/ChatConversationViewSwift.swift @@ -168,6 +168,8 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll self.tableController.scrollBadge!.isHidden = false self.tableController.scrollBadge!.text = "\(ChatConversationViewModel.sharedModel.unread_msg+1)" } + + self.tableControllerSwift.refreshData() } ChatConversationViewModel.sharedModel.stateChanged.observe { state in diff --git a/Classes/Swift/Chat/Views/MultilineMessageCell.swift b/Classes/Swift/Chat/Views/MultilineMessageCell.swift index aff1c8d87..760ef4287 100644 --- a/Classes/Swift/Chat/Views/MultilineMessageCell.swift +++ b/Classes/Swift/Chat/Views/MultilineMessageCell.swift @@ -1175,7 +1175,6 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI downloadContentCollection[indexTransferProgress]!.downloadButtonLabel.isHidden = true downloadContentCollection[indexTransferProgress]!.circularProgressBarView.isHidden = false - //downloadContentCollection[indexTransferProgress]!.downloadProgressBar.isHidden = false } DispatchQueue.main.async(execute: { [self] in @@ -1189,7 +1188,6 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI indexTransferProgress = -1 } else { downloadContentCollection[indexTransferProgress]!.setUpCircularProgressBarView(toValue: p) - //downloadContentCollection[indexTransferProgress]!.downloadProgressBar.setProgress(p, animated: true) } }) }