From 7c0acc8ccf3e63ad43cff6477de69a28505c53d1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 2 Mar 2021 10:54:37 +0100 Subject: [PATCH] Simplify code --- .../edithistory/ViewEditHistoryViewModel.kt | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/edithistory/ViewEditHistoryViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/edithistory/ViewEditHistoryViewModel.kt index 061743e163..1307341446 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/edithistory/ViewEditHistoryViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/edithistory/ViewEditHistoryViewModel.kt @@ -83,26 +83,24 @@ class ViewEditHistoryViewModel @AssistedInject constructor(@Assisted val events = data.map { event -> val timelineID = event.roomId + UUID.randomUUID().toString() - event.also { - // We need to check encryption - if (it.isEncrypted() && it.mxDecryptionResult == null) { - // for now decrypt sync - try { - val result = session.cryptoService().decryptEvent(it, timelineID) - it.mxDecryptionResult = OlmDecryptionResult( - payload = result.clearEvent, - senderKey = result.senderCurve25519Key, - keysClaimed = result.claimedEd25519Key?.let { k -> mapOf("ed25519" to k) }, - forwardingCurve25519KeyChain = result.forwardingCurve25519KeyChain - ) - } catch (e: MXCryptoError) { - Timber.w("Failed to decrypt event in history") - } + // We need to check encryption + if (event.isEncrypted() && event.mxDecryptionResult == null) { + // for now decrypt sync + try { + val result = session.cryptoService().decryptEvent(event, timelineID) + event.mxDecryptionResult = OlmDecryptionResult( + payload = result.clearEvent, + senderKey = result.senderCurve25519Key, + keysClaimed = result.claimedEd25519Key?.let { k -> mapOf("ed25519" to k) }, + forwardingCurve25519KeyChain = result.forwardingCurve25519KeyChain + ) + } catch (e: MXCryptoError) { + Timber.w("Failed to decrypt event in history") } + } - if (event.eventId == it.eventId) { - originalIsReply = it.isReply() - } + if (event.eventId == event.eventId) { + originalIsReply = event.isReply() } } setState {