Simplify code

This commit is contained in:
Benoit Marty 2021-03-02 10:54:37 +01:00
parent d2b39e5cb8
commit 7c0acc8ccf
1 changed files with 16 additions and 18 deletions

View File

@ -83,13 +83,12 @@ class ViewEditHistoryViewModel @AssistedInject constructor(@Assisted
val events = data.map { event -> val events = data.map { event ->
val timelineID = event.roomId + UUID.randomUUID().toString() val timelineID = event.roomId + UUID.randomUUID().toString()
event.also {
// We need to check encryption // We need to check encryption
if (it.isEncrypted() && it.mxDecryptionResult == null) { if (event.isEncrypted() && event.mxDecryptionResult == null) {
// for now decrypt sync // for now decrypt sync
try { try {
val result = session.cryptoService().decryptEvent(it, timelineID) val result = session.cryptoService().decryptEvent(event, timelineID)
it.mxDecryptionResult = OlmDecryptionResult( event.mxDecryptionResult = OlmDecryptionResult(
payload = result.clearEvent, payload = result.clearEvent,
senderKey = result.senderCurve25519Key, senderKey = result.senderCurve25519Key,
keysClaimed = result.claimedEd25519Key?.let { k -> mapOf("ed25519" to k) }, keysClaimed = result.claimedEd25519Key?.let { k -> mapOf("ed25519" to k) },
@ -100,9 +99,8 @@ class ViewEditHistoryViewModel @AssistedInject constructor(@Assisted
} }
} }
if (event.eventId == it.eventId) { if (event.eventId == event.eventId) {
originalIsReply = it.isReply() originalIsReply = event.isReply()
}
} }
} }
setState { setState {