Improved chat room scroll

This commit is contained in:
Sylvain Berfini 2022-07-01 11:23:27 +02:00
parent 21e500cad3
commit 6406eb9d7b

View file

@ -80,14 +80,11 @@ class DetailChatRoomFragment : MasterFragment<ChatRoomDetailFragmentBinding, Cha
// First time we fill the list with messages // First time we fill the list with messages
Log.i("[Chat Room] History first $itemCount messages loaded") Log.i("[Chat Room] History first $itemCount messages loaded")
} else { } else {
// Scroll to newly added messages automatically // Scroll to newly added messages automatically only if user hasn't initiated a scroll up in the messages history
if (positionStart == adapter.itemCount - itemCount) { if (viewModel.isUserScrollingUp.value == false) {
// But only if user hasn't initiated a scroll up in the messages history scrollToFirstUnreadMessageOrBottom(false)
if (viewModel.isUserScrollingUp.value == false) { } else {
scrollToFirstUnreadMessageOrBottom(false) Log.d("[Chat Room] User has scrolled up manually in the messages history, don't scroll to the newly added message at the bottom & don't mark the chat room as read")
} else {
Log.d("[Chat Room] User has scrolled up manually in the messages history, don't scroll to the newly added message at the bottom & don't mark the chat room as read")
}
} }
} }
} }