|
|
@ -55,6 +55,11 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|
|
|
return messagesTableView.contentSize.height - tableViewUnobscuredHeight
|
|
|
|
return messagesTableView.contentSize.height - tableViewUnobscuredHeight
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isCloseToBottom: Bool {
|
|
|
|
|
|
|
|
let margin = (self.lastPageTop - self.messagesTableView.contentOffset.y)
|
|
|
|
|
|
|
|
return margin <= ConversationVC.scrollToBottomMargin
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lazy var mnemonic: String = {
|
|
|
|
lazy var mnemonic: String = {
|
|
|
|
let identityManager = OWSIdentityManager.shared()
|
|
|
|
let identityManager = OWSIdentityManager.shared()
|
|
|
|
let databaseConnection = identityManager.value(forKey: "dbConnection") as! YapDatabaseConnection
|
|
|
|
let databaseConnection = identityManager.value(forKey: "dbConnection") as! YapDatabaseConnection
|
|
|
@ -314,6 +319,13 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|
|
|
baselineKeyboardHeight = newHeight
|
|
|
|
baselineKeyboardHeight = newHeight
|
|
|
|
self.messagesTableView.keyboardHeight = 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)
|
|
|
|
scrollButtonConstraint?.constant = -(newHeight + 16)
|
|
|
|
let newContentOffsetY = max(self.messagesTableView.contentOffset.y + min(lastPageTop, 0) + newHeight - self.messagesTableView.keyboardHeight, 0.0)
|
|
|
|
let newContentOffsetY = max(self.messagesTableView.contentOffset.y + min(lastPageTop, 0) + newHeight - self.messagesTableView.keyboardHeight, 0.0)
|
|
|
|
self.messagesTableView.contentOffset.y = newContentOffsetY
|
|
|
|
self.messagesTableView.contentOffset.y = newContentOffsetY
|
|
|
@ -353,13 +365,11 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|
|
|
if update.viewItem?.interaction is TSOutgoingMessage {
|
|
|
|
if update.viewItem?.interaction is TSOutgoingMessage {
|
|
|
|
shouldScrollToBottom = true
|
|
|
|
shouldScrollToBottom = true
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
let margin = (self.lastPageTop - self.messagesTableView.contentOffset.y)
|
|
|
|
shouldScrollToBottom = self.isCloseToBottom
|
|
|
|
shouldScrollToBottom = margin <= ConversationVC.scrollToBottomMargin
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case .update:
|
|
|
|
case .update:
|
|
|
|
self.messagesTableView.reloadRows(at: [ IndexPath(row: Int(update.oldIndex), section: 0) ], with: .fade)
|
|
|
|
self.messagesTableView.reloadRows(at: [ IndexPath(row: Int(update.oldIndex), section: 0) ], with: .fade)
|
|
|
|
let margin = (self.lastPageTop - self.messagesTableView.contentOffset.y)
|
|
|
|
shouldScrollToBottom = self.isCloseToBottom
|
|
|
|
shouldScrollToBottom = margin <= ConversationVC.scrollToBottomMargin
|
|
|
|
|
|
|
|
default: preconditionFailure()
|
|
|
|
default: preconditionFailure()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|