Merge pull request #6791 from thundernest/fix_list_update_during_swipe

Change the way the message view is updated on message list changes
This commit is contained in:
cketti 2023-03-30 13:03:27 +02:00 committed by GitHub
commit 1a99201f0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -138,6 +138,8 @@ class MessageViewContainerFragment : Fragment() {
return
}
val oldPosition = viewPager.currentItem
adapter.messageList = messageListItems
// We only set the adapter on ViewPager2 after the message list has been loaded. This way ViewPager2 can
@ -147,7 +149,12 @@ class MessageViewContainerFragment : Fragment() {
}
val position = adapter.getPosition(messageReference)
viewPager.setCurrentItem(position, false)
if (position != oldPosition) {
// The current message now has a different position in the updated list. So point the view pager to it.
// Note: This cancels ongoing swipe actions/animations. We might want to change this to defer list updates
// until after swipe actions have been completed.
viewPager.setCurrentItem(position, false)
}
}
private fun setActiveMessage(position: Int) {