From ee27d3e047740a10c0d7b287f984ee5525ff5382 Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 8 Jul 2019 12:49:22 +0200 Subject: [PATCH] Fix / clear unknown session map before re-request decrypt --- .../session/room/timeline/TimelineEventDecryptor.kt | 8 ++++++-- .../room/detail/timeline/factory/EncryptedItemFactory.kt | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventDecryptor.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventDecryptor.kt index e67fba381a..483a0a4741 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventDecryptor.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/timeline/TimelineEventDecryptor.kt @@ -38,12 +38,16 @@ internal class TimelineEventDecryptor( private val newSessionListener = object : NewSessionListener { override fun onNewSession(roomId: String?, senderKey: String, sessionId: String) { synchronized(unknownSessionsFailure) { + val toDecryptAgain = ArrayList() unknownSessionsFailure[sessionId]?.let { eventIds -> - eventIds.forEach { + toDecryptAgain.addAll(eventIds) + } + if (toDecryptAgain.isNotEmpty()) { + unknownSessionsFailure[sessionId]?.clear() + toDecryptAgain.forEach { requestDecryption(it) } } - unknownSessionsFailure[sessionId]?.clear() } } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/EncryptedItemFactory.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/EncryptedItemFactory.kt index d3c42cd5d6..2a4a0c0f67 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/EncryptedItemFactory.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/factory/EncryptedItemFactory.kt @@ -55,7 +55,8 @@ class EncryptedItemFactory @Inject constructor(private val messageInformationDat cryptoError?.name } - val message = stringProvider.getString(R.string.notice_crypto_unable_to_decrypt, errorDescription) + val message = stringProvider.getString(R.string.encrypted_message).takeIf { cryptoError == null } + ?: stringProvider.getString(R.string.notice_crypto_unable_to_decrypt, errorDescription) val spannableStr = span(message) { textStyle = "italic" textColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_secondary)