Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 1a99201f authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #6791 from thundernest/fix_list_update_during_swipe

Change the way the message view is updated on message list changes
parents 01d0b8bc b86fcd39
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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,8 +149,13 @@ class MessageViewContainerFragment : Fragment() {
        }

        val position = adapter.getPosition(messageReference)
        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) {
        val newMessageReference = adapter.getMessageReference(position) ?: return