diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/ThreadDetailsViewModel.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/ThreadDetailsViewModel.kt index a7b018f40..1a48c635b 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/ThreadDetailsViewModel.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/jetpack/viewmodel/ThreadDetailsViewModel.kt @@ -442,7 +442,7 @@ class ThreadDetailsViewModel( } } } - }.reversed() + } val fetchedDraftIdsMap = if (messagesInThread.any { it.isDraft() }) { GmailApiHelper.loadBaseDraftInfoInParallel( diff --git a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt index 6cad6b17e..901bcf436 100644 --- a/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt +++ b/FlowCrypt/src/main/java/com/flowcrypt/email/ui/activity/fragment/ThreadDetailsFragment.kt @@ -156,7 +156,7 @@ class ThreadDetailsFragment : BaseFragment(), Prog object : MessagesInThreadListAdapter.AdapterListener { override fun onDataSubmitted(list: List?) { val freshestMessageInConversation = - (list?.getOrNull(1) as? MessagesInThreadListAdapter.Message) + (list?.lastOrNull() as? MessagesInThreadListAdapter.Message) updateThreadReplyButtons( if (freshestMessageInConversation?.messageEntity?.isDraft == true) { null @@ -429,7 +429,7 @@ class ThreadDetailsFragment : BaseFragment(), Prog binding?.layoutReplyButtons?.replyAllButton?.gone() binding?.layoutReplyButtons?.forwardButton?.gone() - binding?.recyclerViewThreads?.apply { + binding?.recyclerViewMessages?.apply { val linearLayoutManager = LinearLayoutManager(context) layoutManager = linearLayoutManager addItemDecoration( @@ -1056,13 +1056,14 @@ class ThreadDetailsFragment : BaseFragment(), Prog } val existing = messagesInThreadListAdapter.currentList.getOrNull(1) as? MessagesInThreadListAdapter.Message - val firstMessage = data[1] as? MessagesInThreadListAdapter.Message + val lastMessage = data.lastOrNull() as? MessagesInThreadListAdapter.Message if (!hasProcessedMessages && existing != null && existing.type == MessagesInThreadListAdapter.Type.MESSAGE_COLLAPSED && existing.incomingMessageInfo == null ) { - if (firstMessage != null && firstMessage.incomingMessageInfo == null) { - processMessageClick(firstMessage) + if (lastMessage != null && lastMessage.incomingMessageInfo == null) { + binding?.recyclerViewMessages?.layoutManager?.scrollToPosition(data.size - 1) + processMessageClick(lastMessage) } } } diff --git a/FlowCrypt/src/main/res/layout/fragment_thread_details.xml b/FlowCrypt/src/main/res/layout/fragment_thread_details.xml index e9b915139..bbf5736c4 100644 --- a/FlowCrypt/src/main/res/layout/fragment_thread_details.xml +++ b/FlowCrypt/src/main/res/layout/fragment_thread_details.xml @@ -39,7 +39,7 @@ app:layout_constraintTop_toTopOf="parent" /> @@ -65,7 +68,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:visibility="gone" - app:constraint_referenced_ids="layoutReplyButtons,recyclerViewThreads" /> + app:constraint_referenced_ids="layoutReplyButtons,recyclerViewMessages" />