Retain scroll position when deleting messages

Removed the call to `refreshMessages()` as it's not really needed here and also because it'll reset the scroll position in some cases
This commit is contained in:
Naveen 2022-11-19 22:46:18 +05:30
parent c6d453f5ab
commit 398c2237bc
2 changed files with 5 additions and 3 deletions

View file

@ -230,7 +230,9 @@ class ThreadAdapter(
fun updateMessages(newMessages: ArrayList<ThreadItem>, scrollPosition: Int = newMessages.lastIndex) {
val latestMessages = newMessages.toMutableList()
submitList(latestMessages) {
recyclerView.scrollToPosition(scrollPosition)
if (scrollPosition != -1) {
recyclerView.scrollToPosition(scrollPosition)
}
}
}