minor improvements on scroll to bottom

pull/541/head
Ryan Zhao 3 years ago
parent ec40922cb4
commit 885ab66550

@ -77,7 +77,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
return Mnemonic.encode(hexEncodedString: hexEncodedSeed) return Mnemonic.encode(hexEncodedString: hexEncodedSeed)
}() }()
lazy var viewModel = ConversationViewModel(thread: thread, focusMessageIdOnOpen: focusedMessageID, delegate: self) lazy var viewModel = ConversationViewModel(thread: thread, focusMessageIdOnOpen: nil, delegate: self)
lazy var mediaCache: NSCache<NSString, AnyObject> = { lazy var mediaCache: NSCache<NSString, AnyObject> = {
let result = NSCache<NSString, AnyObject>() let result = NSCache<NSString, AnyObject>()
@ -515,7 +515,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
// needed for proper calculations, so force an initial layout if it doesn't have a size) // needed for proper calculations, so force an initial layout if it doesn't have a size)
var hasDoneLayout: Bool = true var hasDoneLayout: Bool = true
if messageRequestView.bounds.height <= CGFloat.leastNonzeroMagnitude { if thread.isMessageRequest() && messageRequestView.bounds.height <= CGFloat.leastNonzeroMagnitude {
hasDoneLayout = false hasDoneLayout = false
UIView.performWithoutAnimation { UIView.performWithoutAnimation {
@ -735,16 +735,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
func scrollToBottom(isAnimated: Bool) { func scrollToBottom(isAnimated: Bool) {
guard !isUserScrolling else { return } guard !isUserScrolling else { return }
if let interactionID = viewItems.last?.interaction.uniqueId { messagesTableView.scrollToRow(at: IndexPath(row: viewItems.count - 1, section: 0), at: .top, animated: isAnimated)
self.scrollToInteraction(with: interactionID, position: .top, isAnimated: isAnimated)
return
}
// Ensure the view is fully up to date before we try to scroll to the bottom, since
// we use the table view's bounds to determine where the bottom is.
view.layoutIfNeeded()
let firstContentPageTop: CGFloat = 0
let contentOffsetY = max(firstContentPageTop, lastPageTop)
messagesTableView.setContentOffset(CGPoint(x: 0, y: contentOffsetY), animated: isAnimated)
} }
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {

Loading…
Cancel
Save