Speed up sent state display for local echo

This commit is contained in:
Benoit Marty 2021-03-09 17:19:27 +01:00 committed by Benoit Marty
parent 3ca25f9006
commit b7c0951cbe

View File

@ -31,7 +31,6 @@ import org.matrix.android.sdk.api.crypto.VerificationState
import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.LocalEcho
import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.ReferencesAggregatedContent import org.matrix.android.sdk.api.session.room.model.ReferencesAggregatedContent
import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent import org.matrix.android.sdk.api.session.room.model.message.MessageAudioContent
@ -91,8 +90,7 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
eventSendState = event.root.sendState, eventSendState = event.root.sendState,
prevEventSendState = prevEvent?.root?.sendState, prevEventSendState = prevEvent?.root?.sendState,
anyReadReceipts = event.readReceipts.any { it.user.userId != session.myUserId }, anyReadReceipts = event.readReceipts.any { it.user.userId != session.myUserId },
isMedia = isMedia, isMedia = isMedia
isLocalEcho = LocalEcho.isLocalEchoId(event.eventId)
) )
} else { } else {
SendStateDecoration.NONE SendStateDecoration.NONE
@ -144,14 +142,11 @@ class MessageInformationDataFactory @Inject constructor(private val session: Ses
) )
} }
private fun getSendStateDecoration( private fun getSendStateDecoration(eventSendState: SendState,
eventSendState: SendState, prevEventSendState: SendState?,
prevEventSendState: SendState?, anyReadReceipts: Boolean,
anyReadReceipts: Boolean, isMedia: Boolean): SendStateDecoration {
isMedia: Boolean, return if (eventSendState.isSending()) {
isLocalEcho: Boolean
): SendStateDecoration {
return if (eventSendState.isSending() || (eventSendState.isSent() && isLocalEcho)) {
if (isMedia) SendStateDecoration.SENDING_MEDIA else SendStateDecoration.SENDING_NON_MEDIA if (isMedia) SendStateDecoration.SENDING_MEDIA else SendStateDecoration.SENDING_NON_MEDIA
} else if (eventSendState.hasFailed()) { } else if (eventSendState.hasFailed()) {
SendStateDecoration.FAILED SendStateDecoration.FAILED