Merge pull request #2927 from nextcloud/bugfix/2926/fixScrollToFirstUnreadMessage

Fix to scroll to first unread message
This commit is contained in:
Andy Scherzinger 2023-04-08 21:34:29 +02:00 committed by GitHub
commit 0695c811df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2523,7 +2523,16 @@ class ChatActivity :
addMessagesToAdapter(shouldAddNewMessagesNotice, chatMessageList)
if (shouldAddNewMessagesNotice && adapter != null) {
layoutManager?.scrollToPosition(0)
scrollToFirstUnreadMessage()
}
}
private fun scrollToFirstUnreadMessage() {
adapter?.let {
layoutManager?.scrollToPositionWithOffset(
it.getMessagePositionByIdInReverse("-1"),
binding.messagesListView.height / 2
)
}
}