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

Commit b86fcd39 authored by cketti's avatar cketti
Browse files

Change the way the message view is updated on message list changes

parent 5c4bde51
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