mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Hopefully fix scrolling issue
This commit is contained in:
parent
e8d8377a04
commit
c5c75a306e
1 changed files with 14 additions and 4 deletions
|
@ -55,6 +55,11 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
return messagesTableView.contentSize.height - tableViewUnobscuredHeight
|
||||
}
|
||||
|
||||
var isCloseToBottom: Bool {
|
||||
let margin = (self.lastPageTop - self.messagesTableView.contentOffset.y)
|
||||
return margin <= ConversationVC.scrollToBottomMargin
|
||||
}
|
||||
|
||||
lazy var mnemonic: String = {
|
||||
let identityManager = OWSIdentityManager.shared()
|
||||
let databaseConnection = identityManager.value(forKey: "dbConnection") as! YapDatabaseConnection
|
||||
|
@ -314,6 +319,13 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
baselineKeyboardHeight = newHeight
|
||||
self.messagesTableView.keyboardHeight = newHeight
|
||||
}
|
||||
let margin = (self.lastPageTop - self.messagesTableView.contentOffset.y)
|
||||
// HACK: If the keyboard is coming up and we're very close to the bottom, scroll to the
|
||||
// bottom. This "fixes" an issue where the conversation would randomly scroll up sometimes
|
||||
// when bringing up the keyboard.
|
||||
if newHeight > 200 && margin <= 2 {
|
||||
scrollToBottom(isAnimated: false)
|
||||
}
|
||||
scrollButtonConstraint?.constant = -(newHeight + 16)
|
||||
let newContentOffsetY = max(self.messagesTableView.contentOffset.y + min(lastPageTop, 0) + newHeight - self.messagesTableView.keyboardHeight, 0.0)
|
||||
self.messagesTableView.contentOffset.y = newContentOffsetY
|
||||
|
@ -353,13 +365,11 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
if update.viewItem?.interaction is TSOutgoingMessage {
|
||||
shouldScrollToBottom = true
|
||||
} else {
|
||||
let margin = (self.lastPageTop - self.messagesTableView.contentOffset.y)
|
||||
shouldScrollToBottom = margin <= ConversationVC.scrollToBottomMargin
|
||||
shouldScrollToBottom = self.isCloseToBottom
|
||||
}
|
||||
case .update:
|
||||
self.messagesTableView.reloadRows(at: [ IndexPath(row: Int(update.oldIndex), section: 0) ], with: .fade)
|
||||
let margin = (self.lastPageTop - self.messagesTableView.contentOffset.y)
|
||||
shouldScrollToBottom = margin <= ConversationVC.scrollToBottomMargin
|
||||
shouldScrollToBottom = self.isCloseToBottom
|
||||
default: preconditionFailure()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue