Skip to content

Commit

Permalink
Migrated to use the logic "show the freshest in the bottom".| #74
Browse files Browse the repository at this point in the history
  • Loading branch information
DenBond7 committed Dec 2, 2024
1 parent 72a420c commit b350b6f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ class ThreadDetailsViewModel(
}
}
}
}.reversed()
}

val fetchedDraftIdsMap = if (messagesInThread.any { it.isDraft() }) {
GmailApiHelper.loadBaseDraftInfoInParallel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class ThreadDetailsFragment : BaseFragment<FragmentThreadDetailsBinding>(), Prog
object : MessagesInThreadListAdapter.AdapterListener {
override fun onDataSubmitted(list: List<MessagesInThreadListAdapter.Item>?) {
val freshestMessageInConversation =
(list?.getOrNull(1) as? MessagesInThreadListAdapter.Message)
(list?.lastOrNull() as? MessagesInThreadListAdapter.Message)
updateThreadReplyButtons(
if (freshestMessageInConversation?.messageEntity?.isDraft == true) {
null
Expand Down Expand Up @@ -429,7 +429,7 @@ class ThreadDetailsFragment : BaseFragment<FragmentThreadDetailsBinding>(), Prog
binding?.layoutReplyButtons?.replyAllButton?.gone()
binding?.layoutReplyButtons?.forwardButton?.gone()

binding?.recyclerViewThreads?.apply {
binding?.recyclerViewMessages?.apply {
val linearLayoutManager = LinearLayoutManager(context)
layoutManager = linearLayoutManager
addItemDecoration(
Expand Down Expand Up @@ -1056,13 +1056,14 @@ class ThreadDetailsFragment : BaseFragment<FragmentThreadDetailsBinding>(), 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)
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions FlowCrypt/src/main/res/layout/fragment_thread_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@
app:layout_constraintTop_toTopOf="parent" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewThreads"
android:id="@+id/recyclerViewMessages"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/layoutReplyButtons"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:itemCount="8"
android:clipToPadding="false"
android:paddingBottom="64dp"
android:scrollbars="vertical"
tools:listitem="@layout/item_message_in_thread_collapsed">

</androidx.recyclerview.widget.RecyclerView>
Expand All @@ -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" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down

0 comments on commit b350b6f

Please sign in to comment.