Replying to a conversation replies to the last message which is not a draft
both when executed from "more actions" menu and from "bottom bar". The same applies for reply all and forward actions. - Conversation Details expands the last message that is not a draft Moved the responsibility to decide which message is expanded when the adapter is inited from the `ExpandableRecyclerAdapter` to `MessageDetailsAdapter`, to allow checking in the message state and avoid expanding draft messages. The above, on top of being the desired behavior, was needed to ensure that when replying to a conversation the body and `decryptedHtml` fields of the last message that is not a draft had actually been loaded (as they are needed to pass the "quoted text" over to the composer for replying / forwarding). MAILAND-2199
This commit is contained in:
parent
e70f68e893
commit
189bb3b623
|
@ -427,7 +427,19 @@ internal class MessageDetailsAdapter(
|
|||
items.add(MessageDetailsListItem(message))
|
||||
items.add(MessageDetailsListItem(message, message.decryptedHTML, message.decryptedHTML))
|
||||
}
|
||||
|
||||
setItems(items)
|
||||
expandLastNonDraftItem()
|
||||
}
|
||||
|
||||
private fun expandLastNonDraftItem() {
|
||||
val lastNonDraftHeaderIndex = visibleItems?.indexOfLast {
|
||||
!it.message.isDraft() && it.itemType == TYPE_HEADER
|
||||
} ?: return
|
||||
|
||||
if (!isExpanded(lastNonDraftHeaderIndex)) {
|
||||
toggleExpandedItems(lastNonDraftHeaderIndex, true)
|
||||
}
|
||||
}
|
||||
|
||||
fun setExclusiveLabelsPerMessage(labels: HashMap<String, List<Label>>) {
|
||||
|
|
|
@ -461,13 +461,13 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
|
|||
private inner class ConversationUiModelObserver : Observer<ConversationUiModel> {
|
||||
|
||||
override fun onChanged(conversation: ConversationUiModel) {
|
||||
val lastMessage = conversation.messages.last()
|
||||
val lastNonDraftMessage = conversation.messages.last { it.isDraft().not() }
|
||||
|
||||
setupToolbarOffsetListener(conversation.messages.count())
|
||||
displayToolbarData(conversation)
|
||||
setupLastMessageActionsListener(lastMessage)
|
||||
setupLastMessageActionsListener(lastNonDraftMessage)
|
||||
|
||||
Timber.v("New decrypted message ${lastMessage.messageId}")
|
||||
Timber.v("New decrypted message ${lastNonDraftMessage.messageId}")
|
||||
viewModel.renderedFromCache = AtomicBoolean(true)
|
||||
|
||||
Timber.v("setMessage conversations size: ${conversation.messages.size}")
|
||||
|
@ -616,7 +616,7 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
|
|||
/**
|
||||
* Legacy method to executes reply, reply_all and forward op
|
||||
* @param messageOrConversationId the message or conversation ID on which to perform the action on.
|
||||
* Passing a conversation ID will cause the action to be applied to the last message.
|
||||
* Passing a conversation ID will cause the action to be applied to the last message that is not a draft.
|
||||
*/
|
||||
fun executeMessageAction(
|
||||
messageAction: Constants.MessageActionType,
|
||||
|
@ -626,7 +626,7 @@ internal class MessageDetailsActivity : BaseStoragePermissionActivity() {
|
|||
val message = requireNotNull(
|
||||
viewModel.decryptedConversationUiModel.value?.messages?.find {
|
||||
it.messageId == messageOrConversationId
|
||||
} ?: viewModel.decryptedConversationUiModel.value?.messages?.last()
|
||||
} ?: viewModel.decryptedConversationUiModel.value?.messages?.last { it.isDraft().not() }
|
||||
)
|
||||
val user = mUserManager.requireCurrentLegacyUser()
|
||||
val userUsedSpace = user.usedSpace
|
||||
|
|
|
@ -154,17 +154,6 @@ abstract class ExpandableRecyclerAdapter<T : ExpandableRecyclerAdapter.ListItem>
|
|||
|
||||
this.visibleItems = visibleItems
|
||||
|
||||
for (i in visibleItems.indices) {
|
||||
if (getItemViewType(i) == TYPE_HEADER) {
|
||||
if (isExpanded(i)) {
|
||||
break
|
||||
} else {
|
||||
if (i == visibleItems.size - 1) {
|
||||
expandItems(i, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue